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

Merge branches 'core', 'cxgb4', 'ipoib', 'iser', 'iwcm', 'mad', 'misc', 'mlx4', 'mlx5', 'ocrdma' and 'srp' into for-next

+1432 -447
+9 -4
Documentation/infiniband/user_mad.txt
··· 26 26 ioctl. Also, all agents registered through a file descriptor will 27 27 be unregistered when the descriptor is closed. 28 28 29 + 2014 -- a new registration ioctl is now provided which allows additional 30 + fields to be provided during registration. 31 + Users of this registration call are implicitly setting the use of 32 + pkey_index (see below). 33 + 29 34 Receiving MADs 30 35 31 36 MADs are received using read(). The receive side now supports ··· 109 104 The old ib_umad interface did not allow setting the P_Key index for 110 105 MADs that are sent and did not provide a way for obtaining the P_Key 111 106 index of received MADs. A new layout for struct ib_user_mad_hdr 112 - with a pkey_index member has been defined; however, to preserve 113 - binary compatibility with older applications, this new layout will 114 - not be used unless the IB_USER_MAD_ENABLE_PKEY ioctl is called 115 - before a file descriptor is used for anything else. 107 + with a pkey_index member has been defined; however, to preserve binary 108 + compatibility with older applications, this new layout will not be used 109 + unless one of IB_USER_MAD_ENABLE_PKEY or IB_USER_MAD_REGISTER_AGENT2 ioctl's 110 + are called before a file descriptor is used for anything else. 116 111 117 112 In September 2008, the IB_USER_MAD_ABI_VERSION will be incremented 118 113 to 6, the new layout of struct ib_user_mad_hdr will be used by
+8 -8
drivers/infiniband/core/agent.c
··· 94 94 port_priv = ib_get_agent_port(device, port_num); 95 95 96 96 if (!port_priv) { 97 - printk(KERN_ERR SPFX "Unable to find port agent\n"); 97 + dev_err(&device->dev, "Unable to find port agent\n"); 98 98 return; 99 99 } 100 100 101 101 agent = port_priv->agent[qpn]; 102 102 ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num); 103 103 if (IS_ERR(ah)) { 104 - printk(KERN_ERR SPFX "ib_create_ah_from_wc error %ld\n", 104 + dev_err(&device->dev, "ib_create_ah_from_wc error %ld\n", 105 105 PTR_ERR(ah)); 106 106 return; 107 107 } ··· 110 110 IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA, 111 111 GFP_KERNEL); 112 112 if (IS_ERR(send_buf)) { 113 - printk(KERN_ERR SPFX "ib_create_send_mad error\n"); 113 + dev_err(&device->dev, "ib_create_send_mad error\n"); 114 114 goto err1; 115 115 } 116 116 ··· 125 125 } 126 126 127 127 if (ib_post_send_mad(send_buf, NULL)) { 128 - printk(KERN_ERR SPFX "ib_post_send_mad error\n"); 128 + dev_err(&device->dev, "ib_post_send_mad error\n"); 129 129 goto err2; 130 130 } 131 131 return; ··· 151 151 /* Create new device info */ 152 152 port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL); 153 153 if (!port_priv) { 154 - printk(KERN_ERR SPFX "No memory for ib_agent_port_private\n"); 154 + dev_err(&device->dev, "No memory for ib_agent_port_private\n"); 155 155 ret = -ENOMEM; 156 156 goto error1; 157 157 } ··· 161 161 port_priv->agent[0] = ib_register_mad_agent(device, port_num, 162 162 IB_QPT_SMI, NULL, 0, 163 163 &agent_send_handler, 164 - NULL, NULL); 164 + NULL, NULL, 0); 165 165 if (IS_ERR(port_priv->agent[0])) { 166 166 ret = PTR_ERR(port_priv->agent[0]); 167 167 goto error2; ··· 172 172 port_priv->agent[1] = ib_register_mad_agent(device, port_num, 173 173 IB_QPT_GSI, NULL, 0, 174 174 &agent_send_handler, 175 - NULL, NULL); 175 + NULL, NULL, 0); 176 176 if (IS_ERR(port_priv->agent[1])) { 177 177 ret = PTR_ERR(port_priv->agent[1]); 178 178 goto error3; ··· 202 202 port_priv = __ib_get_agent_port(device, port_num); 203 203 if (port_priv == NULL) { 204 204 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags); 205 - printk(KERN_ERR SPFX "Port %d not found\n", port_num); 205 + dev_err(&device->dev, "Port %d not found\n", port_num); 206 206 return -ENODEV; 207 207 } 208 208 list_del(&port_priv->port_list);
+3 -2
drivers/infiniband/core/cm.c
··· 3753 3753 struct cm_port *port; 3754 3754 struct ib_mad_reg_req reg_req = { 3755 3755 .mgmt_class = IB_MGMT_CLASS_CM, 3756 - .mgmt_class_version = IB_CM_CLASS_VERSION 3756 + .mgmt_class_version = IB_CM_CLASS_VERSION, 3757 3757 }; 3758 3758 struct ib_port_modify port_modify = { 3759 3759 .set_port_cap_mask = IB_PORT_CM_SUP ··· 3801 3801 0, 3802 3802 cm_send_handler, 3803 3803 cm_recv_handler, 3804 - port); 3804 + port, 3805 + 0); 3805 3806 if (IS_ERR(port->mad_agent)) 3806 3807 goto error2; 3807 3808
+27
drivers/infiniband/core/iwcm.c
··· 46 46 #include <linux/completion.h> 47 47 #include <linux/slab.h> 48 48 #include <linux/module.h> 49 + #include <linux/sysctl.h> 49 50 50 51 #include <rdma/iw_cm.h> 51 52 #include <rdma/ib_addr.h> ··· 64 63 struct list_head list; 65 64 struct iw_cm_event event; 66 65 struct list_head free_list; 66 + }; 67 + 68 + static unsigned int default_backlog = 256; 69 + 70 + static struct ctl_table_header *iwcm_ctl_table_hdr; 71 + static struct ctl_table iwcm_ctl_table[] = { 72 + { 73 + .procname = "default_backlog", 74 + .data = &default_backlog, 75 + .maxlen = sizeof(default_backlog), 76 + .mode = 0644, 77 + .proc_handler = proc_dointvec, 78 + }, 79 + { } 67 80 }; 68 81 69 82 /* ··· 439 424 int ret; 440 425 441 426 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); 427 + 428 + if (!backlog) 429 + backlog = default_backlog; 442 430 443 431 ret = alloc_work_entries(cm_id_priv, backlog); 444 432 if (ret) ··· 1048 1030 if (!iwcm_wq) 1049 1031 return -ENOMEM; 1050 1032 1033 + iwcm_ctl_table_hdr = register_net_sysctl(&init_net, "net/iw_cm", 1034 + iwcm_ctl_table); 1035 + if (!iwcm_ctl_table_hdr) { 1036 + pr_err("iw_cm: couldn't register sysctl paths\n"); 1037 + destroy_workqueue(iwcm_wq); 1038 + return -ENOMEM; 1039 + } 1040 + 1051 1041 return 0; 1052 1042 } 1053 1043 1054 1044 static void __exit iw_cm_cleanup(void) 1055 1045 { 1046 + unregister_net_sysctl_table(iwcm_ctl_table_hdr); 1056 1047 destroy_workqueue(iwcm_wq); 1057 1048 } 1058 1049
+183 -102
drivers/infiniband/core/mad.c
··· 33 33 * SOFTWARE. 34 34 * 35 35 */ 36 + 37 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 38 + 36 39 #include <linux/dma-mapping.h> 37 40 #include <linux/slab.h> 38 41 #include <linux/module.h> ··· 198 195 u8 rmpp_version, 199 196 ib_mad_send_handler send_handler, 200 197 ib_mad_recv_handler recv_handler, 201 - void *context) 198 + void *context, 199 + u32 registration_flags) 202 200 { 203 201 struct ib_mad_port_private *port_priv; 204 202 struct ib_mad_agent *ret = ERR_PTR(-EINVAL); ··· 215 211 216 212 /* Validate parameters */ 217 213 qpn = get_spl_qp_index(qp_type); 218 - if (qpn == -1) 214 + if (qpn == -1) { 215 + dev_notice(&device->dev, 216 + "ib_register_mad_agent: invalid QP Type %d\n", 217 + qp_type); 219 218 goto error1; 219 + } 220 220 221 - if (rmpp_version && rmpp_version != IB_MGMT_RMPP_VERSION) 221 + if (rmpp_version && rmpp_version != IB_MGMT_RMPP_VERSION) { 222 + dev_notice(&device->dev, 223 + "ib_register_mad_agent: invalid RMPP Version %u\n", 224 + rmpp_version); 222 225 goto error1; 226 + } 223 227 224 228 /* Validate MAD registration request if supplied */ 225 229 if (mad_reg_req) { 226 - if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) 230 + if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) { 231 + dev_notice(&device->dev, 232 + "ib_register_mad_agent: invalid Class Version %u\n", 233 + mad_reg_req->mgmt_class_version); 227 234 goto error1; 228 - if (!recv_handler) 235 + } 236 + if (!recv_handler) { 237 + dev_notice(&device->dev, 238 + "ib_register_mad_agent: no recv_handler\n"); 229 239 goto error1; 240 + } 230 241 if (mad_reg_req->mgmt_class >= MAX_MGMT_CLASS) { 231 242 /* 232 243 * IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE is the only 233 244 * one in this range currently allowed 234 245 */ 235 246 if (mad_reg_req->mgmt_class != 236 - IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 247 + IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) { 248 + dev_notice(&device->dev, 249 + "ib_register_mad_agent: Invalid Mgmt Class 0x%x\n", 250 + mad_reg_req->mgmt_class); 237 251 goto error1; 252 + } 238 253 } else if (mad_reg_req->mgmt_class == 0) { 239 254 /* 240 255 * Class 0 is reserved in IBA and is used for 241 256 * aliasing of IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE 242 257 */ 258 + dev_notice(&device->dev, 259 + "ib_register_mad_agent: Invalid Mgmt Class 0\n"); 243 260 goto error1; 244 261 } else if (is_vendor_class(mad_reg_req->mgmt_class)) { 245 262 /* 246 263 * If class is in "new" vendor range, 247 264 * ensure supplied OUI is not zero 248 265 */ 249 - if (!is_vendor_oui(mad_reg_req->oui)) 266 + if (!is_vendor_oui(mad_reg_req->oui)) { 267 + dev_notice(&device->dev, 268 + "ib_register_mad_agent: No OUI specified for class 0x%x\n", 269 + mad_reg_req->mgmt_class); 250 270 goto error1; 271 + } 251 272 } 252 273 /* Make sure class supplied is consistent with RMPP */ 253 274 if (!ib_is_mad_class_rmpp(mad_reg_req->mgmt_class)) { 254 - if (rmpp_version) 275 + if (rmpp_version) { 276 + dev_notice(&device->dev, 277 + "ib_register_mad_agent: RMPP version for non-RMPP class 0x%x\n", 278 + mad_reg_req->mgmt_class); 255 279 goto error1; 280 + } 256 281 } 282 + 257 283 /* Make sure class supplied is consistent with QP type */ 258 284 if (qp_type == IB_QPT_SMI) { 259 285 if ((mad_reg_req->mgmt_class != 260 286 IB_MGMT_CLASS_SUBN_LID_ROUTED) && 261 287 (mad_reg_req->mgmt_class != 262 - IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) 288 + IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) { 289 + dev_notice(&device->dev, 290 + "ib_register_mad_agent: Invalid SM QP type: class 0x%x\n", 291 + mad_reg_req->mgmt_class); 263 292 goto error1; 293 + } 264 294 } else { 265 295 if ((mad_reg_req->mgmt_class == 266 296 IB_MGMT_CLASS_SUBN_LID_ROUTED) || 267 297 (mad_reg_req->mgmt_class == 268 - IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) 298 + IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) { 299 + dev_notice(&device->dev, 300 + "ib_register_mad_agent: Invalid GS QP type: class 0x%x\n", 301 + mad_reg_req->mgmt_class); 269 302 goto error1; 303 + } 270 304 } 271 305 } else { 272 306 /* No registration request supplied */ 273 307 if (!send_handler) 308 + goto error1; 309 + if (registration_flags & IB_MAD_USER_RMPP) 274 310 goto error1; 275 311 } 276 312 277 313 /* Validate device and port */ 278 314 port_priv = ib_get_mad_port(device, port_num); 279 315 if (!port_priv) { 316 + dev_notice(&device->dev, "ib_register_mad_agent: Invalid port\n"); 280 317 ret = ERR_PTR(-ENODEV); 281 318 goto error1; 282 319 } ··· 325 280 /* Verify the QP requested is supported. For example, Ethernet devices 326 281 * will not have QP0 */ 327 282 if (!port_priv->qp_info[qpn].qp) { 283 + dev_notice(&device->dev, 284 + "ib_register_mad_agent: QP %d not supported\n", qpn); 328 285 ret = ERR_PTR(-EPROTONOSUPPORT); 329 286 goto error1; 330 287 } ··· 363 316 mad_agent_priv->agent.context = context; 364 317 mad_agent_priv->agent.qp = port_priv->qp_info[qpn].qp; 365 318 mad_agent_priv->agent.port_num = port_num; 319 + mad_agent_priv->agent.flags = registration_flags; 366 320 spin_lock_init(&mad_agent_priv->lock); 367 321 INIT_LIST_HEAD(&mad_agent_priv->send_list); 368 322 INIT_LIST_HEAD(&mad_agent_priv->wait_list); ··· 754 706 smi_handle_dr_smp_send(smp, device->node_type, port_num) == 755 707 IB_SMI_DISCARD) { 756 708 ret = -EINVAL; 757 - printk(KERN_ERR PFX "Invalid directed route\n"); 709 + dev_err(&device->dev, "Invalid directed route\n"); 758 710 goto out; 759 711 } 760 712 ··· 766 718 local = kmalloc(sizeof *local, GFP_ATOMIC); 767 719 if (!local) { 768 720 ret = -ENOMEM; 769 - printk(KERN_ERR PFX "No memory for ib_mad_local_private\n"); 721 + dev_err(&device->dev, "No memory for ib_mad_local_private\n"); 770 722 goto out; 771 723 } 772 724 local->mad_priv = NULL; ··· 774 726 mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_ATOMIC); 775 727 if (!mad_priv) { 776 728 ret = -ENOMEM; 777 - printk(KERN_ERR PFX "No memory for local response MAD\n"); 729 + dev_err(&device->dev, "No memory for local response MAD\n"); 778 730 kfree(local); 779 731 goto out; 780 732 } ··· 885 837 for (left = send_buf->data_len + pad; left > 0; left -= seg_size) { 886 838 seg = kmalloc(sizeof (*seg) + seg_size, gfp_mask); 887 839 if (!seg) { 888 - printk(KERN_ERR "alloc_send_rmpp_segs: RMPP mem " 889 - "alloc failed for len %zd, gfp %#x\n", 890 - sizeof (*seg) + seg_size, gfp_mask); 840 + dev_err(&send_buf->mad_agent->device->dev, 841 + "alloc_send_rmpp_segs: RMPP mem alloc failed for len %zd, gfp %#x\n", 842 + sizeof (*seg) + seg_size, gfp_mask); 891 843 free_send_rmpp_list(send_wr); 892 844 return -ENOMEM; 893 845 } ··· 910 862 return 0; 911 863 } 912 864 865 + int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent) 866 + { 867 + return agent->rmpp_version && !(agent->flags & IB_MAD_USER_RMPP); 868 + } 869 + EXPORT_SYMBOL(ib_mad_kernel_rmpp_agent); 870 + 913 871 struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent, 914 872 u32 remote_qpn, u16 pkey_index, 915 873 int rmpp_active, ··· 932 878 pad = get_pad_size(hdr_len, data_len); 933 879 message_size = hdr_len + data_len + pad; 934 880 935 - if ((!mad_agent->rmpp_version && 936 - (rmpp_active || message_size > sizeof(struct ib_mad))) || 937 - (!rmpp_active && message_size > sizeof(struct ib_mad))) 938 - return ERR_PTR(-EINVAL); 881 + if (ib_mad_kernel_rmpp_agent(mad_agent)) { 882 + if (!rmpp_active && message_size > sizeof(struct ib_mad)) 883 + return ERR_PTR(-EINVAL); 884 + } else 885 + if (rmpp_active || message_size > sizeof(struct ib_mad)) 886 + return ERR_PTR(-EINVAL); 939 887 940 888 size = rmpp_active ? hdr_len : sizeof(struct ib_mad); 941 889 buf = kzalloc(sizeof *mad_send_wr + size, gfp_mask); ··· 1191 1135 &mad_agent_priv->send_list); 1192 1136 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 1193 1137 1194 - if (mad_agent_priv->agent.rmpp_version) { 1138 + if (ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)) { 1195 1139 ret = ib_send_rmpp_mad(mad_send_wr); 1196 1140 if (ret >= 0 && ret != IB_RMPP_RESULT_CONSUMED) 1197 1141 ret = ib_send_mad(mad_send_wr); ··· 1255 1199 int ib_process_mad_wc(struct ib_mad_agent *mad_agent, 1256 1200 struct ib_wc *wc) 1257 1201 { 1258 - printk(KERN_ERR PFX "ib_process_mad_wc() not implemented yet\n"); 1202 + dev_err(&mad_agent->device->dev, 1203 + "ib_process_mad_wc() not implemented yet\n"); 1259 1204 return 0; 1260 1205 } 1261 1206 EXPORT_SYMBOL(ib_process_mad_wc); ··· 1268 1211 1269 1212 for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS) { 1270 1213 if ((*method)->agent[i]) { 1271 - printk(KERN_ERR PFX "Method %d already in use\n", i); 1214 + pr_err("Method %d already in use\n", i); 1272 1215 return -EINVAL; 1273 1216 } 1274 1217 } ··· 1280 1223 /* Allocate management method table */ 1281 1224 *method = kzalloc(sizeof **method, GFP_ATOMIC); 1282 1225 if (!*method) { 1283 - printk(KERN_ERR PFX "No memory for " 1284 - "ib_mad_mgmt_method_table\n"); 1226 + pr_err("No memory for ib_mad_mgmt_method_table\n"); 1285 1227 return -ENOMEM; 1286 1228 } 1287 1229 ··· 1375 1319 /* Allocate management class table for "new" class version */ 1376 1320 *class = kzalloc(sizeof **class, GFP_ATOMIC); 1377 1321 if (!*class) { 1378 - printk(KERN_ERR PFX "No memory for " 1379 - "ib_mad_mgmt_class_table\n"); 1322 + dev_err(&agent_priv->agent.device->dev, 1323 + "No memory for ib_mad_mgmt_class_table\n"); 1380 1324 ret = -ENOMEM; 1381 1325 goto error1; 1382 1326 } ··· 1442 1386 /* Allocate mgmt vendor class table for "new" class version */ 1443 1387 vendor = kzalloc(sizeof *vendor, GFP_ATOMIC); 1444 1388 if (!vendor) { 1445 - printk(KERN_ERR PFX "No memory for " 1446 - "ib_mad_mgmt_vendor_class_table\n"); 1389 + dev_err(&agent_priv->agent.device->dev, 1390 + "No memory for ib_mad_mgmt_vendor_class_table\n"); 1447 1391 goto error1; 1448 1392 } 1449 1393 ··· 1453 1397 /* Allocate table for this management vendor class */ 1454 1398 vendor_class = kzalloc(sizeof *vendor_class, GFP_ATOMIC); 1455 1399 if (!vendor_class) { 1456 - printk(KERN_ERR PFX "No memory for " 1457 - "ib_mad_mgmt_vendor_class\n"); 1400 + dev_err(&agent_priv->agent.device->dev, 1401 + "No memory for ib_mad_mgmt_vendor_class\n"); 1458 1402 goto error2; 1459 1403 } 1460 1404 ··· 1485 1429 goto check_in_use; 1486 1430 } 1487 1431 } 1488 - printk(KERN_ERR PFX "All OUI slots in use\n"); 1432 + dev_err(&agent_priv->agent.device->dev, "All OUI slots in use\n"); 1489 1433 goto error3; 1490 1434 1491 1435 check_in_use: ··· 1696 1640 if (mad_agent->agent.recv_handler) 1697 1641 atomic_inc(&mad_agent->refcount); 1698 1642 else { 1699 - printk(KERN_NOTICE PFX "No receive handler for client " 1700 - "%p on port %d\n", 1701 - &mad_agent->agent, port_priv->port_num); 1643 + dev_notice(&port_priv->device->dev, 1644 + "No receive handler for client %p on port %d\n", 1645 + &mad_agent->agent, port_priv->port_num); 1702 1646 mad_agent = NULL; 1703 1647 } 1704 1648 } ··· 1714 1658 1715 1659 /* Make sure MAD base version is understood */ 1716 1660 if (mad->mad_hdr.base_version != IB_MGMT_BASE_VERSION) { 1717 - printk(KERN_ERR PFX "MAD received with unsupported base " 1718 - "version %d\n", mad->mad_hdr.base_version); 1661 + pr_err("MAD received with unsupported base version %d\n", 1662 + mad->mad_hdr.base_version); 1719 1663 goto out; 1720 1664 } 1721 1665 ··· 1741 1685 1742 1686 rmpp_mad = (struct ib_rmpp_mad *)mad_hdr; 1743 1687 return !mad_agent_priv->agent.rmpp_version || 1688 + !ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent) || 1744 1689 !(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & 1745 1690 IB_MGMT_RMPP_FLAG_ACTIVE) || 1746 1691 (rmpp_mad->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_DATA); ··· 1869 1812 1870 1813 INIT_LIST_HEAD(&mad_recv_wc->rmpp_list); 1871 1814 list_add(&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list); 1872 - if (mad_agent_priv->agent.rmpp_version) { 1815 + if (ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)) { 1873 1816 mad_recv_wc = ib_process_rmpp_recv_wc(mad_agent_priv, 1874 1817 mad_recv_wc); 1875 1818 if (!mad_recv_wc) { ··· 1884 1827 mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc); 1885 1828 if (!mad_send_wr) { 1886 1829 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 1887 - ib_free_recv_mad(mad_recv_wc); 1888 - deref_mad_agent(mad_agent_priv); 1889 - return; 1830 + if (!ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent) 1831 + && ib_is_mad_class_rmpp(mad_recv_wc->recv_buf.mad->mad_hdr.mgmt_class) 1832 + && (ib_get_rmpp_flags(&((struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad)->rmpp_hdr) 1833 + & IB_MGMT_RMPP_FLAG_ACTIVE)) { 1834 + /* user rmpp is in effect 1835 + * and this is an active RMPP MAD 1836 + */ 1837 + mad_recv_wc->wc->wr_id = 0; 1838 + mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, 1839 + mad_recv_wc); 1840 + atomic_dec(&mad_agent_priv->refcount); 1841 + } else { 1842 + /* not user rmpp, revert to normal behavior and 1843 + * drop the mad */ 1844 + ib_free_recv_mad(mad_recv_wc); 1845 + deref_mad_agent(mad_agent_priv); 1846 + return; 1847 + } 1848 + } else { 1849 + ib_mark_mad_done(mad_send_wr); 1850 + spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 1851 + 1852 + /* Defined behavior is to complete response before request */ 1853 + mad_recv_wc->wc->wr_id = (unsigned long) &mad_send_wr->send_buf; 1854 + mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, 1855 + mad_recv_wc); 1856 + atomic_dec(&mad_agent_priv->refcount); 1857 + 1858 + mad_send_wc.status = IB_WC_SUCCESS; 1859 + mad_send_wc.vendor_err = 0; 1860 + mad_send_wc.send_buf = &mad_send_wr->send_buf; 1861 + ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc); 1890 1862 } 1891 - ib_mark_mad_done(mad_send_wr); 1892 - spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 1893 - 1894 - /* Defined behavior is to complete response before request */ 1895 - mad_recv_wc->wc->wr_id = (unsigned long) &mad_send_wr->send_buf; 1896 - mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, 1897 - mad_recv_wc); 1898 - atomic_dec(&mad_agent_priv->refcount); 1899 - 1900 - mad_send_wc.status = IB_WC_SUCCESS; 1901 - mad_send_wc.vendor_err = 0; 1902 - mad_send_wc.send_buf = &mad_send_wr->send_buf; 1903 - ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc); 1904 1863 } else { 1905 1864 mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, 1906 1865 mad_recv_wc); ··· 1984 1911 1985 1912 response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL); 1986 1913 if (!response) { 1987 - printk(KERN_ERR PFX "ib_mad_recv_done_handler no memory " 1988 - "for response buffer\n"); 1914 + dev_err(&port_priv->device->dev, 1915 + "ib_mad_recv_done_handler no memory for response buffer\n"); 1989 1916 goto out; 1990 1917 } 1991 1918 ··· 2156 2083 2157 2084 mad_agent_priv = mad_send_wr->mad_agent_priv; 2158 2085 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2159 - if (mad_agent_priv->agent.rmpp_version) { 2086 + if (ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)) { 2160 2087 ret = ib_process_rmpp_send_wc(mad_send_wr, mad_send_wc); 2161 2088 if (ret == IB_RMPP_RESULT_CONSUMED) 2162 2089 goto done; ··· 2249 2176 ret = ib_post_send(qp_info->qp, &queued_send_wr->send_wr, 2250 2177 &bad_send_wr); 2251 2178 if (ret) { 2252 - printk(KERN_ERR PFX "ib_post_send failed: %d\n", ret); 2179 + dev_err(&port_priv->device->dev, 2180 + "ib_post_send failed: %d\n", ret); 2253 2181 mad_send_wr = queued_send_wr; 2254 2182 wc->status = IB_WC_LOC_QP_OP_ERR; 2255 2183 goto retry; ··· 2322 2248 IB_QP_STATE | IB_QP_CUR_STATE); 2323 2249 kfree(attr); 2324 2250 if (ret) 2325 - printk(KERN_ERR PFX "mad_error_handler - " 2326 - "ib_modify_qp to RTS : %d\n", ret); 2251 + dev_err(&port_priv->device->dev, 2252 + "mad_error_handler - ib_modify_qp to RTS : %d\n", 2253 + ret); 2327 2254 else 2328 2255 mark_sends_for_retry(qp_info); 2329 2256 } ··· 2483 2408 if (local->mad_priv) { 2484 2409 recv_mad_agent = local->recv_mad_agent; 2485 2410 if (!recv_mad_agent) { 2486 - printk(KERN_ERR PFX "No receive MAD agent for local completion\n"); 2411 + dev_err(&mad_agent_priv->agent.device->dev, 2412 + "No receive MAD agent for local completion\n"); 2487 2413 free_mad = 1; 2488 2414 goto local_send_completion; 2489 2415 } ··· 2552 2476 2553 2477 mad_send_wr->timeout = msecs_to_jiffies(mad_send_wr->send_buf.timeout_ms); 2554 2478 2555 - if (mad_send_wr->mad_agent_priv->agent.rmpp_version) { 2479 + if (ib_mad_kernel_rmpp_agent(&mad_send_wr->mad_agent_priv->agent)) { 2556 2480 ret = ib_retry_rmpp(mad_send_wr); 2557 2481 switch (ret) { 2558 2482 case IB_RMPP_RESULT_UNHANDLED: ··· 2665 2589 } else { 2666 2590 mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL); 2667 2591 if (!mad_priv) { 2668 - printk(KERN_ERR PFX "No memory for receive buffer\n"); 2592 + dev_err(&qp_info->port_priv->device->dev, 2593 + "No memory for receive buffer\n"); 2669 2594 ret = -ENOMEM; 2670 2595 break; 2671 2596 } ··· 2702 2625 sizeof mad_priv->header, 2703 2626 DMA_FROM_DEVICE); 2704 2627 kmem_cache_free(ib_mad_cache, mad_priv); 2705 - printk(KERN_ERR PFX "ib_post_recv failed: %d\n", ret); 2628 + dev_err(&qp_info->port_priv->device->dev, 2629 + "ib_post_recv failed: %d\n", ret); 2706 2630 break; 2707 2631 } 2708 2632 } while (post); ··· 2759 2681 2760 2682 attr = kmalloc(sizeof *attr, GFP_KERNEL); 2761 2683 if (!attr) { 2762 - printk(KERN_ERR PFX "Couldn't kmalloc ib_qp_attr\n"); 2684 + dev_err(&port_priv->device->dev, 2685 + "Couldn't kmalloc ib_qp_attr\n"); 2763 2686 return -ENOMEM; 2764 2687 } 2765 2688 ··· 2784 2705 ret = ib_modify_qp(qp, attr, IB_QP_STATE | 2785 2706 IB_QP_PKEY_INDEX | IB_QP_QKEY); 2786 2707 if (ret) { 2787 - printk(KERN_ERR PFX "Couldn't change QP%d state to " 2788 - "INIT: %d\n", i, ret); 2708 + dev_err(&port_priv->device->dev, 2709 + "Couldn't change QP%d state to INIT: %d\n", 2710 + i, ret); 2789 2711 goto out; 2790 2712 } 2791 2713 2792 2714 attr->qp_state = IB_QPS_RTR; 2793 2715 ret = ib_modify_qp(qp, attr, IB_QP_STATE); 2794 2716 if (ret) { 2795 - printk(KERN_ERR PFX "Couldn't change QP%d state to " 2796 - "RTR: %d\n", i, ret); 2717 + dev_err(&port_priv->device->dev, 2718 + "Couldn't change QP%d state to RTR: %d\n", 2719 + i, ret); 2797 2720 goto out; 2798 2721 } 2799 2722 ··· 2803 2722 attr->sq_psn = IB_MAD_SEND_Q_PSN; 2804 2723 ret = ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_SQ_PSN); 2805 2724 if (ret) { 2806 - printk(KERN_ERR PFX "Couldn't change QP%d state to " 2807 - "RTS: %d\n", i, ret); 2725 + dev_err(&port_priv->device->dev, 2726 + "Couldn't change QP%d state to RTS: %d\n", 2727 + i, ret); 2808 2728 goto out; 2809 2729 } 2810 2730 } 2811 2731 2812 2732 ret = ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP); 2813 2733 if (ret) { 2814 - printk(KERN_ERR PFX "Failed to request completion " 2815 - "notification: %d\n", ret); 2734 + dev_err(&port_priv->device->dev, 2735 + "Failed to request completion notification: %d\n", 2736 + ret); 2816 2737 goto out; 2817 2738 } 2818 2739 ··· 2824 2741 2825 2742 ret = ib_mad_post_receive_mads(&port_priv->qp_info[i], NULL); 2826 2743 if (ret) { 2827 - printk(KERN_ERR PFX "Couldn't post receive WRs\n"); 2744 + dev_err(&port_priv->device->dev, 2745 + "Couldn't post receive WRs\n"); 2828 2746 goto out; 2829 2747 } 2830 2748 } ··· 2839 2755 struct ib_mad_qp_info *qp_info = qp_context; 2840 2756 2841 2757 /* It's worse than that! He's dead, Jim! */ 2842 - printk(KERN_ERR PFX "Fatal error (%d) on MAD QP (%d)\n", 2758 + dev_err(&qp_info->port_priv->device->dev, 2759 + "Fatal error (%d) on MAD QP (%d)\n", 2843 2760 event->event, qp_info->qp->qp_num); 2844 2761 } 2845 2762 ··· 2886 2801 qp_init_attr.event_handler = qp_event_handler; 2887 2802 qp_info->qp = ib_create_qp(qp_info->port_priv->pd, &qp_init_attr); 2888 2803 if (IS_ERR(qp_info->qp)) { 2889 - printk(KERN_ERR PFX "Couldn't create ib_mad QP%d\n", 2890 - get_spl_qp_index(qp_type)); 2804 + dev_err(&qp_info->port_priv->device->dev, 2805 + "Couldn't create ib_mad QP%d\n", 2806 + get_spl_qp_index(qp_type)); 2891 2807 ret = PTR_ERR(qp_info->qp); 2892 2808 goto error; 2893 2809 } ··· 2926 2840 /* Create new device info */ 2927 2841 port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL); 2928 2842 if (!port_priv) { 2929 - printk(KERN_ERR PFX "No memory for ib_mad_port_private\n"); 2843 + dev_err(&device->dev, "No memory for ib_mad_port_private\n"); 2930 2844 return -ENOMEM; 2931 2845 } 2932 2846 ··· 2946 2860 ib_mad_thread_completion_handler, 2947 2861 NULL, port_priv, cq_size, 0); 2948 2862 if (IS_ERR(port_priv->cq)) { 2949 - printk(KERN_ERR PFX "Couldn't create ib_mad CQ\n"); 2863 + dev_err(&device->dev, "Couldn't create ib_mad CQ\n"); 2950 2864 ret = PTR_ERR(port_priv->cq); 2951 2865 goto error3; 2952 2866 } 2953 2867 2954 2868 port_priv->pd = ib_alloc_pd(device); 2955 2869 if (IS_ERR(port_priv->pd)) { 2956 - printk(KERN_ERR PFX "Couldn't create ib_mad PD\n"); 2870 + dev_err(&device->dev, "Couldn't create ib_mad PD\n"); 2957 2871 ret = PTR_ERR(port_priv->pd); 2958 2872 goto error4; 2959 2873 } 2960 2874 2961 2875 port_priv->mr = ib_get_dma_mr(port_priv->pd, IB_ACCESS_LOCAL_WRITE); 2962 2876 if (IS_ERR(port_priv->mr)) { 2963 - printk(KERN_ERR PFX "Couldn't get ib_mad DMA MR\n"); 2877 + dev_err(&device->dev, "Couldn't get ib_mad DMA MR\n"); 2964 2878 ret = PTR_ERR(port_priv->mr); 2965 2879 goto error5; 2966 2880 } ··· 2988 2902 2989 2903 ret = ib_mad_port_start(port_priv); 2990 2904 if (ret) { 2991 - printk(KERN_ERR PFX "Couldn't start port\n"); 2905 + dev_err(&device->dev, "Couldn't start port\n"); 2992 2906 goto error9; 2993 2907 } 2994 2908 ··· 3032 2946 port_priv = __ib_get_mad_port(device, port_num); 3033 2947 if (port_priv == NULL) { 3034 2948 spin_unlock_irqrestore(&ib_mad_port_list_lock, flags); 3035 - printk(KERN_ERR PFX "Port %d not found\n", port_num); 2949 + dev_err(&device->dev, "Port %d not found\n", port_num); 3036 2950 return -ENODEV; 3037 2951 } 3038 2952 list_del_init(&port_priv->port_list); ··· 3070 2984 3071 2985 for (i = start; i <= end; i++) { 3072 2986 if (ib_mad_port_open(device, i)) { 3073 - printk(KERN_ERR PFX "Couldn't open %s port %d\n", 3074 - device->name, i); 2987 + dev_err(&device->dev, "Couldn't open port %d\n", i); 3075 2988 goto error; 3076 2989 } 3077 2990 if (ib_agent_port_open(device, i)) { 3078 - printk(KERN_ERR PFX "Couldn't open %s port %d " 3079 - "for agents\n", 3080 - device->name, i); 2991 + dev_err(&device->dev, 2992 + "Couldn't open port %d for agents\n", i); 3081 2993 goto error_agent; 3082 2994 } 3083 2995 } ··· 3083 2999 3084 3000 error_agent: 3085 3001 if (ib_mad_port_close(device, i)) 3086 - printk(KERN_ERR PFX "Couldn't close %s port %d\n", 3087 - device->name, i); 3002 + dev_err(&device->dev, "Couldn't close port %d\n", i); 3088 3003 3089 3004 error: 3090 3005 i--; 3091 3006 3092 3007 while (i >= start) { 3093 3008 if (ib_agent_port_close(device, i)) 3094 - printk(KERN_ERR PFX "Couldn't close %s port %d " 3095 - "for agents\n", 3096 - device->name, i); 3009 + dev_err(&device->dev, 3010 + "Couldn't close port %d for agents\n", i); 3097 3011 if (ib_mad_port_close(device, i)) 3098 - printk(KERN_ERR PFX "Couldn't close %s port %d\n", 3099 - device->name, i); 3012 + dev_err(&device->dev, "Couldn't close port %d\n", i); 3100 3013 i--; 3101 3014 } 3102 3015 } ··· 3114 3033 } 3115 3034 for (i = 0; i < num_ports; i++, cur_port++) { 3116 3035 if (ib_agent_port_close(device, cur_port)) 3117 - printk(KERN_ERR PFX "Couldn't close %s port %d " 3118 - "for agents\n", 3119 - device->name, cur_port); 3036 + dev_err(&device->dev, 3037 + "Couldn't close port %d for agents\n", 3038 + cur_port); 3120 3039 if (ib_mad_port_close(device, cur_port)) 3121 - printk(KERN_ERR PFX "Couldn't close %s port %d\n", 3122 - device->name, cur_port); 3040 + dev_err(&device->dev, "Couldn't close port %d\n", 3041 + cur_port); 3123 3042 } 3124 3043 } 3125 3044 ··· 3145 3064 SLAB_HWCACHE_ALIGN, 3146 3065 NULL); 3147 3066 if (!ib_mad_cache) { 3148 - printk(KERN_ERR PFX "Couldn't create ib_mad cache\n"); 3067 + pr_err("Couldn't create ib_mad cache\n"); 3149 3068 ret = -ENOMEM; 3150 3069 goto error1; 3151 3070 } ··· 3153 3072 INIT_LIST_HEAD(&ib_mad_port_list); 3154 3073 3155 3074 if (ib_register_client(&mad_client)) { 3156 - printk(KERN_ERR PFX "Couldn't register ib_mad client\n"); 3075 + pr_err("Couldn't register ib_mad client\n"); 3157 3076 ret = -EINVAL; 3158 3077 goto error2; 3159 3078 }
-3
drivers/infiniband/core/mad_priv.h
··· 42 42 #include <rdma/ib_mad.h> 43 43 #include <rdma/ib_smi.h> 44 44 45 - 46 - #define PFX "ib_mad: " 47 - 48 45 #define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */ 49 46 50 47 /* QP and CQ parameters */
+1 -1
drivers/infiniband/core/sa_query.c
··· 1184 1184 sa_dev->port[i].agent = 1185 1185 ib_register_mad_agent(device, i + s, IB_QPT_GSI, 1186 1186 NULL, 0, send_handler, 1187 - recv_handler, sa_dev); 1187 + recv_handler, sa_dev, 0); 1188 1188 if (IS_ERR(sa_dev->port[i].agent)) 1189 1189 goto err; 1190 1190
+164 -24
drivers/infiniband/core/user_mad.c
··· 33 33 * SOFTWARE. 34 34 */ 35 35 36 + #define pr_fmt(fmt) "user_mad: " fmt 37 + 36 38 #include <linux/module.h> 37 39 #include <linux/init.h> 38 40 #include <linux/device.h> ··· 506 504 507 505 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data; 508 506 hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class); 509 - if (!ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)) { 510 - copy_offset = IB_MGMT_MAD_HDR; 511 - rmpp_active = 0; 512 - } else { 507 + 508 + if (ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class) 509 + && ib_mad_kernel_rmpp_agent(agent)) { 513 510 copy_offset = IB_MGMT_RMPP_HDR; 514 511 rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & 515 - IB_MGMT_RMPP_FLAG_ACTIVE; 512 + IB_MGMT_RMPP_FLAG_ACTIVE; 513 + } else { 514 + copy_offset = IB_MGMT_MAD_HDR; 515 + rmpp_active = 0; 516 516 } 517 517 518 518 data_len = count - hdr_size(file) - hdr_len; ··· 560 556 rmpp_mad->mad_hdr.tid = *tid; 561 557 } 562 558 563 - spin_lock_irq(&file->send_lock); 564 - ret = is_duplicate(file, packet); 565 - if (!ret) 559 + if (!ib_mad_kernel_rmpp_agent(agent) 560 + && ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class) 561 + && (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) { 562 + spin_lock_irq(&file->send_lock); 566 563 list_add_tail(&packet->list, &file->send_list); 567 - spin_unlock_irq(&file->send_lock); 568 - if (ret) { 569 - ret = -EINVAL; 570 - goto err_msg; 564 + spin_unlock_irq(&file->send_lock); 565 + } else { 566 + spin_lock_irq(&file->send_lock); 567 + ret = is_duplicate(file, packet); 568 + if (!ret) 569 + list_add_tail(&packet->list, &file->send_list); 570 + spin_unlock_irq(&file->send_lock); 571 + if (ret) { 572 + ret = -EINVAL; 573 + goto err_msg; 574 + } 571 575 } 572 576 573 577 ret = ib_post_send_mad(packet->msg, NULL); ··· 626 614 mutex_lock(&file->mutex); 627 615 628 616 if (!file->port->ib_dev) { 617 + dev_notice(file->port->dev, 618 + "ib_umad_reg_agent: invalid device\n"); 629 619 ret = -EPIPE; 630 620 goto out; 631 621 } ··· 638 624 } 639 625 640 626 if (ureq.qpn != 0 && ureq.qpn != 1) { 627 + dev_notice(file->port->dev, 628 + "ib_umad_reg_agent: invalid QPN %d specified\n", 629 + ureq.qpn); 641 630 ret = -EINVAL; 642 631 goto out; 643 632 } ··· 649 632 if (!__get_agent(file, agent_id)) 650 633 goto found; 651 634 635 + dev_notice(file->port->dev, 636 + "ib_umad_reg_agent: Max Agents (%u) reached\n", 637 + IB_UMAD_MAX_AGENTS); 652 638 ret = -ENOMEM; 653 639 goto out; 654 640 655 641 found: 656 642 if (ureq.mgmt_class) { 643 + memset(&req, 0, sizeof(req)); 657 644 req.mgmt_class = ureq.mgmt_class; 658 645 req.mgmt_class_version = ureq.mgmt_class_version; 659 646 memcpy(req.oui, ureq.oui, sizeof req.oui); ··· 678 657 ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI, 679 658 ureq.mgmt_class ? &req : NULL, 680 659 ureq.rmpp_version, 681 - send_handler, recv_handler, file); 660 + send_handler, recv_handler, file, 0); 682 661 if (IS_ERR(agent)) { 683 662 ret = PTR_ERR(agent); 684 663 agent = NULL; ··· 694 673 if (!file->already_used) { 695 674 file->already_used = 1; 696 675 if (!file->use_pkey_index) { 697 - printk(KERN_WARNING "user_mad: process %s did not enable " 698 - "P_Key index support.\n", current->comm); 699 - printk(KERN_WARNING "user_mad: Documentation/infiniband/user_mad.txt " 700 - "has info on the new ABI.\n"); 676 + dev_warn(file->port->dev, 677 + "process %s did not enable P_Key index support.\n", 678 + current->comm); 679 + dev_warn(file->port->dev, 680 + " Documentation/infiniband/user_mad.txt has info on the new ABI.\n"); 701 681 } 702 682 } 703 683 ··· 715 693 716 694 return ret; 717 695 } 696 + 697 + static int ib_umad_reg_agent2(struct ib_umad_file *file, void __user *arg) 698 + { 699 + struct ib_user_mad_reg_req2 ureq; 700 + struct ib_mad_reg_req req; 701 + struct ib_mad_agent *agent = NULL; 702 + int agent_id; 703 + int ret; 704 + 705 + mutex_lock(&file->port->file_mutex); 706 + mutex_lock(&file->mutex); 707 + 708 + if (!file->port->ib_dev) { 709 + dev_notice(file->port->dev, 710 + "ib_umad_reg_agent2: invalid device\n"); 711 + ret = -EPIPE; 712 + goto out; 713 + } 714 + 715 + if (copy_from_user(&ureq, arg, sizeof(ureq))) { 716 + ret = -EFAULT; 717 + goto out; 718 + } 719 + 720 + if (ureq.qpn != 0 && ureq.qpn != 1) { 721 + dev_notice(file->port->dev, 722 + "ib_umad_reg_agent2: invalid QPN %d specified\n", 723 + ureq.qpn); 724 + ret = -EINVAL; 725 + goto out; 726 + } 727 + 728 + if (ureq.flags & ~IB_USER_MAD_REG_FLAGS_CAP) { 729 + dev_notice(file->port->dev, 730 + "ib_umad_reg_agent2 failed: invalid registration flags specified 0x%x; supported 0x%x\n", 731 + ureq.flags, IB_USER_MAD_REG_FLAGS_CAP); 732 + ret = -EINVAL; 733 + 734 + if (put_user((u32)IB_USER_MAD_REG_FLAGS_CAP, 735 + (u32 __user *) (arg + offsetof(struct 736 + ib_user_mad_reg_req2, flags)))) 737 + ret = -EFAULT; 738 + 739 + goto out; 740 + } 741 + 742 + for (agent_id = 0; agent_id < IB_UMAD_MAX_AGENTS; ++agent_id) 743 + if (!__get_agent(file, agent_id)) 744 + goto found; 745 + 746 + dev_notice(file->port->dev, 747 + "ib_umad_reg_agent2: Max Agents (%u) reached\n", 748 + IB_UMAD_MAX_AGENTS); 749 + ret = -ENOMEM; 750 + goto out; 751 + 752 + found: 753 + if (ureq.mgmt_class) { 754 + memset(&req, 0, sizeof(req)); 755 + req.mgmt_class = ureq.mgmt_class; 756 + req.mgmt_class_version = ureq.mgmt_class_version; 757 + if (ureq.oui & 0xff000000) { 758 + dev_notice(file->port->dev, 759 + "ib_umad_reg_agent2 failed: oui invalid 0x%08x\n", 760 + ureq.oui); 761 + ret = -EINVAL; 762 + goto out; 763 + } 764 + req.oui[2] = ureq.oui & 0x0000ff; 765 + req.oui[1] = (ureq.oui & 0x00ff00) >> 8; 766 + req.oui[0] = (ureq.oui & 0xff0000) >> 16; 767 + memcpy(req.method_mask, ureq.method_mask, 768 + sizeof(req.method_mask)); 769 + } 770 + 771 + agent = ib_register_mad_agent(file->port->ib_dev, file->port->port_num, 772 + ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI, 773 + ureq.mgmt_class ? &req : NULL, 774 + ureq.rmpp_version, 775 + send_handler, recv_handler, file, 776 + ureq.flags); 777 + if (IS_ERR(agent)) { 778 + ret = PTR_ERR(agent); 779 + agent = NULL; 780 + goto out; 781 + } 782 + 783 + if (put_user(agent_id, 784 + (u32 __user *)(arg + 785 + offsetof(struct ib_user_mad_reg_req2, id)))) { 786 + ret = -EFAULT; 787 + goto out; 788 + } 789 + 790 + if (!file->already_used) { 791 + file->already_used = 1; 792 + file->use_pkey_index = 1; 793 + } 794 + 795 + file->agent[agent_id] = agent; 796 + ret = 0; 797 + 798 + out: 799 + mutex_unlock(&file->mutex); 800 + 801 + if (ret && agent) 802 + ib_unregister_mad_agent(agent); 803 + 804 + mutex_unlock(&file->port->file_mutex); 805 + 806 + return ret; 807 + } 808 + 718 809 719 810 static int ib_umad_unreg_agent(struct ib_umad_file *file, u32 __user *arg) 720 811 { ··· 884 749 return ib_umad_unreg_agent(filp->private_data, (__u32 __user *) arg); 885 750 case IB_USER_MAD_ENABLE_PKEY: 886 751 return ib_umad_enable_pkey(filp->private_data); 752 + case IB_USER_MAD_REGISTER_AGENT2: 753 + return ib_umad_reg_agent2(filp->private_data, (void __user *) arg); 887 754 default: 888 755 return -ENOIOCTLCMD; 889 756 } ··· 902 765 return ib_umad_unreg_agent(filp->private_data, compat_ptr(arg)); 903 766 case IB_USER_MAD_ENABLE_PKEY: 904 767 return ib_umad_enable_pkey(filp->private_data); 768 + case IB_USER_MAD_REGISTER_AGENT2: 769 + return ib_umad_reg_agent2(filp->private_data, compat_ptr(arg)); 905 770 default: 906 771 return -ENOIOCTLCMD; 907 772 } ··· 1122 983 1123 984 static dev_t overflow_maj; 1124 985 static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS); 1125 - static int find_overflow_devnum(void) 986 + static int find_overflow_devnum(struct ib_device *device) 1126 987 { 1127 988 int ret; 1128 989 ··· 1130 991 ret = alloc_chrdev_region(&overflow_maj, 0, IB_UMAD_MAX_PORTS * 2, 1131 992 "infiniband_mad"); 1132 993 if (ret) { 1133 - printk(KERN_ERR "user_mad: couldn't register dynamic device number\n"); 994 + dev_err(&device->dev, 995 + "couldn't register dynamic device number\n"); 1134 996 return ret; 1135 997 } 1136 998 } ··· 1154 1014 devnum = find_first_zero_bit(dev_map, IB_UMAD_MAX_PORTS); 1155 1015 if (devnum >= IB_UMAD_MAX_PORTS) { 1156 1016 spin_unlock(&port_lock); 1157 - devnum = find_overflow_devnum(); 1017 + devnum = find_overflow_devnum(device); 1158 1018 if (devnum < 0) 1159 1019 return -1; 1160 1020 ··· 1340 1200 ret = register_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2, 1341 1201 "infiniband_mad"); 1342 1202 if (ret) { 1343 - printk(KERN_ERR "user_mad: couldn't register device number\n"); 1203 + pr_err("couldn't register device number\n"); 1344 1204 goto out; 1345 1205 } 1346 1206 1347 1207 umad_class = class_create(THIS_MODULE, "infiniband_mad"); 1348 1208 if (IS_ERR(umad_class)) { 1349 1209 ret = PTR_ERR(umad_class); 1350 - printk(KERN_ERR "user_mad: couldn't create class infiniband_mad\n"); 1210 + pr_err("couldn't create class infiniband_mad\n"); 1351 1211 goto out_chrdev; 1352 1212 } 1353 1213 ··· 1355 1215 1356 1216 ret = class_create_file(umad_class, &class_attr_abi_version.attr); 1357 1217 if (ret) { 1358 - printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n"); 1218 + pr_err("couldn't create abi_version attribute\n"); 1359 1219 goto out_class; 1360 1220 } 1361 1221 1362 1222 ret = ib_register_client(&umad_client); 1363 1223 if (ret) { 1364 - printk(KERN_ERR "user_mad: couldn't register ib_umad client\n"); 1224 + pr_err("couldn't register ib_umad client\n"); 1365 1225 goto out_class; 1366 1226 } 1367 1227
+5 -2
drivers/infiniband/hw/amso1100/c2_cq.c
··· 260 260 mq->msg_pool.host, dma_unmap_addr(mq, mapping)); 261 261 } 262 262 263 - static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size, 264 - int msg_size) 263 + static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, 264 + size_t q_size, size_t msg_size) 265 265 { 266 266 u8 *pool_start; 267 + 268 + if (q_size > SIZE_MAX / msg_size) 269 + return -EINVAL; 267 270 268 271 pool_start = dma_alloc_coherent(&c2dev->pcidev->dev, q_size * msg_size, 269 272 &mq->host_dma, GFP_KERNEL);
+1
drivers/infiniband/hw/cxgb4/ev.c
··· 182 182 183 183 chp = get_chp(dev, qid); 184 184 if (chp) { 185 + t4_clear_cq_armed(&chp->cq); 185 186 spin_lock_irqsave(&chp->comp_handler_lock, flag); 186 187 (*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context); 187 188 spin_unlock_irqrestore(&chp->comp_handler_lock, flag);
+25 -12
drivers/infiniband/hw/cxgb4/qp.c
··· 1066 1066 struct c4iw_cq *schp) 1067 1067 { 1068 1068 int count; 1069 - int flushed; 1069 + int rq_flushed, sq_flushed; 1070 1070 unsigned long flag; 1071 1071 1072 1072 PDBG("%s qhp %p rchp %p schp %p\n", __func__, qhp, rchp, schp); ··· 1084 1084 1085 1085 c4iw_flush_hw_cq(rchp); 1086 1086 c4iw_count_rcqes(&rchp->cq, &qhp->wq, &count); 1087 - flushed = c4iw_flush_rq(&qhp->wq, &rchp->cq, count); 1087 + rq_flushed = c4iw_flush_rq(&qhp->wq, &rchp->cq, count); 1088 1088 spin_unlock(&qhp->lock); 1089 1089 spin_unlock_irqrestore(&rchp->lock, flag); 1090 - if (flushed) { 1091 - spin_lock_irqsave(&rchp->comp_handler_lock, flag); 1092 - (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context); 1093 - spin_unlock_irqrestore(&rchp->comp_handler_lock, flag); 1094 - } 1095 1090 1096 1091 /* locking hierarchy: cq lock first, then qp lock. */ 1097 1092 spin_lock_irqsave(&schp->lock, flag); 1098 1093 spin_lock(&qhp->lock); 1099 1094 if (schp != rchp) 1100 1095 c4iw_flush_hw_cq(schp); 1101 - flushed = c4iw_flush_sq(qhp); 1096 + sq_flushed = c4iw_flush_sq(qhp); 1102 1097 spin_unlock(&qhp->lock); 1103 1098 spin_unlock_irqrestore(&schp->lock, flag); 1104 - if (flushed) { 1105 - spin_lock_irqsave(&schp->comp_handler_lock, flag); 1106 - (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context); 1107 - spin_unlock_irqrestore(&schp->comp_handler_lock, flag); 1099 + 1100 + if (schp == rchp) { 1101 + if (t4_clear_cq_armed(&rchp->cq) && 1102 + (rq_flushed || sq_flushed)) { 1103 + spin_lock_irqsave(&rchp->comp_handler_lock, flag); 1104 + (*rchp->ibcq.comp_handler)(&rchp->ibcq, 1105 + rchp->ibcq.cq_context); 1106 + spin_unlock_irqrestore(&rchp->comp_handler_lock, flag); 1107 + } 1108 + } else { 1109 + if (t4_clear_cq_armed(&rchp->cq) && rq_flushed) { 1110 + spin_lock_irqsave(&rchp->comp_handler_lock, flag); 1111 + (*rchp->ibcq.comp_handler)(&rchp->ibcq, 1112 + rchp->ibcq.cq_context); 1113 + spin_unlock_irqrestore(&rchp->comp_handler_lock, flag); 1114 + } 1115 + if (t4_clear_cq_armed(&schp->cq) && sq_flushed) { 1116 + spin_lock_irqsave(&schp->comp_handler_lock, flag); 1117 + (*schp->ibcq.comp_handler)(&schp->ibcq, 1118 + schp->ibcq.cq_context); 1119 + spin_unlock_irqrestore(&schp->comp_handler_lock, flag); 1120 + } 1108 1121 } 1109 1122 } 1110 1123
+11
drivers/infiniband/hw/cxgb4/t4.h
··· 531 531 return !wq->rq.queue[wq->rq.size].status.db_off; 532 532 } 533 533 534 + enum t4_cq_flags { 535 + CQ_ARMED = 1, 536 + }; 537 + 534 538 struct t4_cq { 535 539 struct t4_cqe *queue; 536 540 dma_addr_t dma_addr; ··· 555 551 u16 cidx_inc; 556 552 u8 gen; 557 553 u8 error; 554 + unsigned long flags; 558 555 }; 556 + 557 + static inline int t4_clear_cq_armed(struct t4_cq *cq) 558 + { 559 + return test_and_clear_bit(CQ_ARMED, &cq->flags); 560 + } 559 561 560 562 static inline int t4_arm_cq(struct t4_cq *cq, int se) 561 563 { 562 564 u32 val; 563 565 566 + set_bit(CQ_ARMED, &cq->flags); 564 567 while (cq->cidx_inc > CIDXINC_MASK) { 565 568 val = SEINTARM(0) | CIDXINC(CIDXINC_MASK) | TIMERREG(7) | 566 569 INGRESSQID(cq->cqid);
+10 -4
drivers/infiniband/hw/ipath/ipath_mad.c
··· 726 726 * @dd: the infinipath device 727 727 * @pkeys: the PKEY table 728 728 */ 729 - static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys) 729 + static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys, u8 port) 730 730 { 731 731 struct ipath_portdata *pd; 732 732 int i; ··· 759 759 } 760 760 if (changed) { 761 761 u64 pkey; 762 + struct ib_event event; 762 763 763 764 pkey = (u64) dd->ipath_pkeys[0] | 764 765 ((u64) dd->ipath_pkeys[1] << 16) | ··· 769 768 (unsigned long long) pkey); 770 769 ipath_write_kreg(dd, dd->ipath_kregs->kr_partitionkey, 771 770 pkey); 771 + 772 + event.event = IB_EVENT_PKEY_CHANGE; 773 + event.device = &dd->verbs_dev->ibdev; 774 + event.element.port_num = port; 775 + ib_dispatch_event(&event); 772 776 } 773 777 return 0; 774 778 } 775 779 776 780 static int recv_subn_set_pkeytable(struct ib_smp *smp, 777 - struct ib_device *ibdev) 781 + struct ib_device *ibdev, u8 port) 778 782 { 779 783 u32 startpx = 32 * (be32_to_cpu(smp->attr_mod) & 0xffff); 780 784 __be16 *p = (__be16 *) smp->data; ··· 790 784 for (i = 0; i < n; i++) 791 785 q[i] = be16_to_cpu(p[i]); 792 786 793 - if (startpx != 0 || set_pkeys(dev->dd, q) != 0) 787 + if (startpx != 0 || set_pkeys(dev->dd, q, port) != 0) 794 788 smp->status |= IB_SMP_INVALID_FIELD; 795 789 796 790 return recv_subn_get_pkeytable(smp, ibdev); ··· 1348 1342 ret = recv_subn_set_portinfo(smp, ibdev, port_num); 1349 1343 goto bail; 1350 1344 case IB_SMP_ATTR_PKEY_TABLE: 1351 - ret = recv_subn_set_pkeytable(smp, ibdev); 1345 + ret = recv_subn_set_pkeytable(smp, ibdev, port_num); 1352 1346 goto bail; 1353 1347 case IB_SMP_ATTR_SM_INFO: 1354 1348 if (dev->port_cap_flags & IB_PORT_SM_DISABLED) {
+1 -1
drivers/infiniband/hw/mlx4/mad.c
··· 891 891 agent = ib_register_mad_agent(&dev->ib_dev, p + 1, 892 892 q ? IB_QPT_GSI : IB_QPT_SMI, 893 893 NULL, 0, send_handler, 894 - NULL, NULL); 894 + NULL, NULL, 0); 895 895 if (IS_ERR(agent)) { 896 896 ret = PTR_ERR(agent); 897 897 goto err;
+2 -4
drivers/infiniband/hw/mlx4/main.c
··· 910 910 const struct default_rules *pdefault_rules = default_table; 911 911 u8 link_layer = rdma_port_get_link_layer(qp->device, flow_attr->port); 912 912 913 - for (i = 0; i < sizeof(default_table)/sizeof(default_table[0]); i++, 914 - pdefault_rules++) { 913 + for (i = 0; i < ARRAY_SIZE(default_table); i++, pdefault_rules++) { 915 914 __u32 field_types[IB_FLOW_SPEC_SUPPORT_LAYERS]; 916 915 memset(&field_types, 0, sizeof(field_types)); 917 916 ··· 964 965 int size = 0; 965 966 int i; 966 967 967 - for (i = 0; i < sizeof(pdefault_rules->rules_create_list)/ 968 - sizeof(pdefault_rules->rules_create_list[0]); i++) { 968 + for (i = 0; i < ARRAY_SIZE(pdefault_rules->rules_create_list); i++) { 969 969 int ret; 970 970 union ib_flow_spec ib_spec; 971 971 switch (pdefault_rules->rules_create_list[i]) {
+1 -1
drivers/infiniband/hw/mlx5/qp.c
··· 2501 2501 spin_lock_irqsave(&qp->sq.lock, flags); 2502 2502 2503 2503 for (nreq = 0; wr; nreq++, wr = wr->next) { 2504 - if (unlikely(wr->opcode >= sizeof(mlx5_ib_opcode) / sizeof(mlx5_ib_opcode[0]))) { 2504 + if (unlikely(wr->opcode >= ARRAY_SIZE(mlx5_ib_opcode))) { 2505 2505 mlx5_ib_warn(dev, "\n"); 2506 2506 err = -EINVAL; 2507 2507 *bad_wr = wr;
+1 -1
drivers/infiniband/hw/mthca/mthca_mad.c
··· 294 294 agent = ib_register_mad_agent(&dev->ib_dev, p + 1, 295 295 q ? IB_QPT_GSI : IB_QPT_SMI, 296 296 NULL, 0, send_handler, 297 - NULL, NULL); 297 + NULL, NULL, 0); 298 298 if (IS_ERR(agent)) { 299 299 ret = PTR_ERR(agent); 300 300 goto err;
+24 -2
drivers/infiniband/hw/ocrdma/ocrdma.h
··· 40 40 #include <be_roce.h> 41 41 #include "ocrdma_sli.h" 42 42 43 - #define OCRDMA_ROCE_DRV_VERSION "10.2.145.0u" 43 + #define OCRDMA_ROCE_DRV_VERSION "10.2.287.0u" 44 44 45 45 #define OCRDMA_ROCE_DRV_DESC "Emulex OneConnect RoCE Driver" 46 46 #define OCRDMA_NODE_DESC "Emulex OneConnect RoCE HCA" ··· 137 137 u16 cqe_status; 138 138 u16 ext_status; 139 139 bool cmd_done; 140 + bool fw_error_state; 140 141 }; 141 142 142 143 struct ocrdma_hw_mr { ··· 236 235 struct list_head entry; 237 236 struct rcu_head rcu; 238 237 int id; 239 - u64 stag_arr[OCRDMA_MAX_STAG]; 238 + u64 *stag_arr; 239 + u8 sl; /* service level */ 240 + bool pfc_state; 241 + atomic_t update_sl; 240 242 u16 pvid; 241 243 u32 asic_id; 242 244 ··· 520 516 521 517 return (dev->asic_id & OCRDMA_SLI_ASIC_GEN_NUM_MASK) >> 522 518 OCRDMA_SLI_ASIC_GEN_NUM_SHIFT; 519 + } 520 + 521 + static inline u8 ocrdma_get_pfc_prio(u8 *pfc, u8 prio) 522 + { 523 + return *(pfc + prio); 524 + } 525 + 526 + static inline u8 ocrdma_get_app_prio(u8 *app_prio, u8 prio) 527 + { 528 + return *(app_prio + prio); 529 + } 530 + 531 + static inline u8 ocrdma_is_enabled_and_synced(u32 state) 532 + { /* May also be used to interpret TC-state, QCN-state 533 + * Appl-state and Logical-link-state in future. 534 + */ 535 + return (state & OCRDMA_STATE_FLAG_ENABLED) && 536 + (state & OCRDMA_STATE_FLAG_SYNC); 523 537 } 524 538 525 539 #endif
+5 -1
drivers/infiniband/hw/ocrdma/ocrdma_ah.c
··· 35 35 #include "ocrdma_ah.h" 36 36 #include "ocrdma_hw.h" 37 37 38 + #define OCRDMA_VID_PCP_SHIFT 0xD 39 + 38 40 static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah, 39 41 struct ib_ah_attr *attr, int pdid) 40 42 { ··· 57 55 if (vlan_tag && (vlan_tag < 0x1000)) { 58 56 eth.eth_type = cpu_to_be16(0x8100); 59 57 eth.roce_eth_type = cpu_to_be16(OCRDMA_ROCE_ETH_TYPE); 60 - vlan_tag |= (attr->sl & 7) << 13; 58 + vlan_tag |= (dev->sl & 0x07) << OCRDMA_VID_PCP_SHIFT; 61 59 eth.vlan_tag = cpu_to_be16(vlan_tag); 62 60 eth_sz = sizeof(struct ocrdma_eth_vlan); 63 61 vlan_enabled = true; ··· 102 100 if (!(attr->ah_flags & IB_AH_GRH)) 103 101 return ERR_PTR(-EINVAL); 104 102 103 + if (atomic_cmpxchg(&dev->update_sl, 1, 0)) 104 + ocrdma_init_service_level(dev); 105 105 ah = kzalloc(sizeof(*ah), GFP_ATOMIC); 106 106 if (!ah) 107 107 return ERR_PTR(-ENOMEM);
+210 -17
drivers/infiniband/hw/ocrdma/ocrdma_hw.c
··· 525 525 526 526 cmd->ev_cnt_flags = OCRDMA_CREATE_CQ_DEF_FLAGS; 527 527 cmd->eqn = eq->id; 528 - cmd->cqe_count = cq->size / sizeof(struct ocrdma_mcqe); 528 + cmd->pdid_cqecnt = cq->size / sizeof(struct ocrdma_mcqe); 529 529 530 530 ocrdma_build_q_pages(&cmd->pa[0], cq->size / OCRDMA_MIN_Q_PAGE_SIZE, 531 531 cq->dma, PAGE_SIZE_4K); ··· 661 661 { 662 662 struct ocrdma_qp *qp = NULL; 663 663 struct ocrdma_cq *cq = NULL; 664 - struct ib_event ib_evt = { 0 }; 664 + struct ib_event ib_evt; 665 665 int cq_event = 0; 666 666 int qp_event = 1; 667 667 int srq_event = 0; ··· 673 673 qp = dev->qp_tbl[cqe->qpvalid_qpid & OCRDMA_AE_MCQE_QPID_MASK]; 674 674 if (cqe->cqvalid_cqid & OCRDMA_AE_MCQE_CQVALID) 675 675 cq = dev->cq_tbl[cqe->cqvalid_cqid & OCRDMA_AE_MCQE_CQID_MASK]; 676 + 677 + memset(&ib_evt, 0, sizeof(ib_evt)); 676 678 677 679 ib_evt.device = &dev->ibdev; 678 680 ··· 772 770 dev->pvid = ((evt->tag_enabled & 773 771 OCRDMA_AE_PVID_MCQE_TAG_MASK) >> 774 772 OCRDMA_AE_PVID_MCQE_TAG_SHIFT); 773 + break; 774 + 775 + case OCRDMA_ASYNC_EVENT_COS_VALUE: 776 + atomic_set(&dev->update_sl, 1); 775 777 break; 776 778 default: 777 779 /* Not interested evts. */ ··· 968 962 msecs_to_jiffies(30000)); 969 963 if (status) 970 964 return 0; 971 - else 965 + else { 966 + dev->mqe_ctx.fw_error_state = true; 967 + pr_err("%s(%d) mailbox timeout: fw not responding\n", 968 + __func__, dev->id); 972 969 return -1; 970 + } 973 971 } 974 972 975 973 /* issue a mailbox command on the MQ */ ··· 985 975 struct ocrdma_mbx_rsp *rsp = NULL; 986 976 987 977 mutex_lock(&dev->mqe_ctx.lock); 978 + if (dev->mqe_ctx.fw_error_state) 979 + goto mbx_err; 988 980 ocrdma_post_mqe(dev, mqe); 989 981 status = ocrdma_wait_mqe_cmpl(dev); 990 982 if (status) ··· 1090 1078 OCRDMA_MBX_QUERY_CFG_CA_ACK_DELAY_SHIFT; 1091 1079 attr->max_mw = rsp->max_mw; 1092 1080 attr->max_mr = rsp->max_mr; 1093 - attr->max_mr_size = ~0ull; 1081 + attr->max_mr_size = ((u64)rsp->max_mr_size_hi << 32) | 1082 + rsp->max_mr_size_lo; 1094 1083 attr->max_fmr = 0; 1095 1084 attr->max_pages_per_frmr = rsp->max_pages_per_frmr; 1096 1085 attr->max_num_mr_pbl = rsp->max_num_mr_pbl; ··· 1265 1252 ctrl_attr_rsp = (struct ocrdma_get_ctrl_attribs_rsp *)dma.va; 1266 1253 hba_attribs = &ctrl_attr_rsp->ctrl_attribs.hba_attribs; 1267 1254 1268 - dev->hba_port_num = hba_attribs->phy_port; 1255 + dev->hba_port_num = (hba_attribs->ptpnum_maxdoms_hbast_cv & 1256 + OCRDMA_HBA_ATTRB_PTNUM_MASK) 1257 + >> OCRDMA_HBA_ATTRB_PTNUM_SHIFT; 1269 1258 strncpy(dev->model_number, 1270 1259 hba_attribs->controller_model_number, 31); 1271 1260 } ··· 1317 1302 goto mbx_err; 1318 1303 1319 1304 rsp = (struct ocrdma_get_link_speed_rsp *)cmd; 1320 - *lnk_speed = rsp->phys_port_speed; 1305 + *lnk_speed = (rsp->pflt_pps_ld_pnum & OCRDMA_PHY_PS_MASK) 1306 + >> OCRDMA_PHY_PS_SHIFT; 1321 1307 1322 1308 mbx_err: 1323 1309 kfree(cmd); ··· 1344 1328 goto mbx_err; 1345 1329 1346 1330 rsp = (struct ocrdma_get_phy_info_rsp *)cmd; 1347 - dev->phy.phy_type = le16_to_cpu(rsp->phy_type); 1331 + dev->phy.phy_type = 1332 + (rsp->ityp_ptyp & OCRDMA_PHY_TYPE_MASK); 1333 + dev->phy.interface_type = 1334 + (rsp->ityp_ptyp & OCRDMA_IF_TYPE_MASK) 1335 + >> OCRDMA_IF_TYPE_SHIFT; 1348 1336 dev->phy.auto_speeds_supported = 1349 - le16_to_cpu(rsp->auto_speeds_supported); 1337 + (rsp->fspeed_aspeed & OCRDMA_ASPEED_SUPP_MASK); 1350 1338 dev->phy.fixed_speeds_supported = 1351 - le16_to_cpu(rsp->fixed_speeds_supported); 1339 + (rsp->fspeed_aspeed & OCRDMA_FSPEED_SUPP_MASK) 1340 + >> OCRDMA_FSPEED_SUPP_SHIFT; 1352 1341 mbx_err: 1353 1342 kfree(cmd); 1354 1343 return status; ··· 1478 1457 1479 1458 pbes = (struct ocrdma_pbe *)dev->av_tbl.pbl.va; 1480 1459 for (i = 0; i < dev->av_tbl.size / OCRDMA_MIN_Q_PAGE_SIZE; i++) { 1481 - pbes[i].pa_lo = (u32) (pa & 0xffffffff); 1482 - pbes[i].pa_hi = (u32) upper_32_bits(pa); 1460 + pbes[i].pa_lo = (u32)cpu_to_le32(pa & 0xffffffff); 1461 + pbes[i].pa_hi = (u32)cpu_to_le32(upper_32_bits(pa)); 1483 1462 pa += PAGE_SIZE; 1484 1463 } 1485 1464 cmd->tbl_addr[0].lo = (u32)(dev->av_tbl.pbl.pa & 0xFFFFFFFF); ··· 1522 1501 ocrdma_mbx_cmd(dev, (struct ocrdma_mqe *)cmd); 1523 1502 dma_free_coherent(&pdev->dev, dev->av_tbl.size, dev->av_tbl.va, 1524 1503 dev->av_tbl.pa); 1504 + dev->av_tbl.va = NULL; 1525 1505 dma_free_coherent(&pdev->dev, PAGE_SIZE, dev->av_tbl.pbl.va, 1526 1506 dev->av_tbl.pbl.pa); 1527 1507 kfree(cmd); ··· 1646 1624 cmd->cmd.pgsz_pgcnt |= OCRDMA_CREATE_CQ_DPP << 1647 1625 OCRDMA_CREATE_CQ_TYPE_SHIFT; 1648 1626 cq->phase_change = false; 1649 - cmd->cmd.cqe_count = (cq->len / cqe_size); 1627 + cmd->cmd.pdid_cqecnt = (cq->len / cqe_size); 1650 1628 } else { 1651 - cmd->cmd.cqe_count = (cq->len / cqe_size) - 1; 1629 + cmd->cmd.pdid_cqecnt = (cq->len / cqe_size) - 1; 1652 1630 cmd->cmd.ev_cnt_flags |= OCRDMA_CREATE_CQ_FLAGS_AUTO_VALID; 1653 1631 cq->phase_change = true; 1654 1632 } 1655 1633 1656 - cmd->cmd.pd_id = pd_id; /* valid only for v3 */ 1634 + /* pd_id valid only for v3 */ 1635 + cmd->cmd.pdid_cqecnt |= (pd_id << 1636 + OCRDMA_CREATE_CQ_CMD_PDID_SHIFT); 1657 1637 ocrdma_build_q_pages(&cmd->cmd.pa[0], hw_pages, cq->pa, page_size); 1658 1638 status = ocrdma_mbx_cmd(dev, (struct ocrdma_mqe *)cmd); 1659 1639 if (status) ··· 2230 2206 OCRDMA_CREATE_QP_REQ_RQ_CQID_MASK; 2231 2207 qp->rq_cq = cq; 2232 2208 2233 - if (pd->dpp_enabled && pd->num_dpp_qp) { 2209 + if (pd->dpp_enabled && attrs->cap.max_inline_data && pd->num_dpp_qp && 2210 + (attrs->cap.max_inline_data <= dev->attr.max_inline_data)) { 2234 2211 ocrdma_set_create_qp_dpp_cmd(cmd, pd, qp, enable_dpp_cq, 2235 2212 dpp_cq_id); 2236 2213 } ··· 2289 2264 2290 2265 if ((ah_attr->ah_flags & IB_AH_GRH) == 0) 2291 2266 return -EINVAL; 2267 + if (atomic_cmpxchg(&qp->dev->update_sl, 1, 0)) 2268 + ocrdma_init_service_level(qp->dev); 2292 2269 cmd->params.tclass_sq_psn |= 2293 2270 (ah_attr->grh.traffic_class << OCRDMA_QP_PARAMS_TCLASS_SHIFT); 2294 2271 cmd->params.rnt_rc_sl_fl |= ··· 2324 2297 cmd->params.vlan_dmac_b4_to_b5 |= 2325 2298 vlan_id << OCRDMA_QP_PARAMS_VLAN_SHIFT; 2326 2299 cmd->flags |= OCRDMA_QP_PARA_VLAN_EN_VALID; 2300 + cmd->params.rnt_rc_sl_fl |= 2301 + (qp->dev->sl & 0x07) << OCRDMA_QP_PARAMS_SL_SHIFT; 2327 2302 } 2328 2303 return 0; 2329 2304 } ··· 2633 2604 return status; 2634 2605 } 2635 2606 2607 + static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype, 2608 + struct ocrdma_dcbx_cfg *dcbxcfg) 2609 + { 2610 + int status = 0; 2611 + dma_addr_t pa; 2612 + struct ocrdma_mqe cmd; 2613 + 2614 + struct ocrdma_get_dcbx_cfg_req *req = NULL; 2615 + struct ocrdma_get_dcbx_cfg_rsp *rsp = NULL; 2616 + struct pci_dev *pdev = dev->nic_info.pdev; 2617 + struct ocrdma_mqe_sge *mqe_sge = cmd.u.nonemb_req.sge; 2618 + 2619 + memset(&cmd, 0, sizeof(struct ocrdma_mqe)); 2620 + cmd.hdr.pyld_len = max_t (u32, sizeof(struct ocrdma_get_dcbx_cfg_rsp), 2621 + sizeof(struct ocrdma_get_dcbx_cfg_req)); 2622 + req = dma_alloc_coherent(&pdev->dev, cmd.hdr.pyld_len, &pa, GFP_KERNEL); 2623 + if (!req) { 2624 + status = -ENOMEM; 2625 + goto mem_err; 2626 + } 2627 + 2628 + cmd.hdr.spcl_sge_cnt_emb |= (1 << OCRDMA_MQE_HDR_SGE_CNT_SHIFT) & 2629 + OCRDMA_MQE_HDR_SGE_CNT_MASK; 2630 + mqe_sge->pa_lo = (u32) (pa & 0xFFFFFFFFUL); 2631 + mqe_sge->pa_hi = (u32) upper_32_bits(pa); 2632 + mqe_sge->len = cmd.hdr.pyld_len; 2633 + 2634 + memset(req, 0, sizeof(struct ocrdma_get_dcbx_cfg_req)); 2635 + ocrdma_init_mch(&req->hdr, OCRDMA_CMD_GET_DCBX_CONFIG, 2636 + OCRDMA_SUBSYS_DCBX, cmd.hdr.pyld_len); 2637 + req->param_type = ptype; 2638 + 2639 + status = ocrdma_mbx_cmd(dev, &cmd); 2640 + if (status) 2641 + goto mbx_err; 2642 + 2643 + rsp = (struct ocrdma_get_dcbx_cfg_rsp *)req; 2644 + ocrdma_le32_to_cpu(rsp, sizeof(struct ocrdma_get_dcbx_cfg_rsp)); 2645 + memcpy(dcbxcfg, &rsp->cfg, sizeof(struct ocrdma_dcbx_cfg)); 2646 + 2647 + mbx_err: 2648 + dma_free_coherent(&pdev->dev, cmd.hdr.pyld_len, req, pa); 2649 + mem_err: 2650 + return status; 2651 + } 2652 + 2653 + #define OCRDMA_MAX_SERVICE_LEVEL_INDEX 0x08 2654 + #define OCRDMA_DEFAULT_SERVICE_LEVEL 0x05 2655 + 2656 + static int ocrdma_parse_dcbxcfg_rsp(struct ocrdma_dev *dev, int ptype, 2657 + struct ocrdma_dcbx_cfg *dcbxcfg, 2658 + u8 *srvc_lvl) 2659 + { 2660 + int status = -EINVAL, indx, slindx; 2661 + int ventry_cnt; 2662 + struct ocrdma_app_parameter *app_param; 2663 + u8 valid, proto_sel; 2664 + u8 app_prio, pfc_prio; 2665 + u16 proto; 2666 + 2667 + if (!(dcbxcfg->tcv_aev_opv_st & OCRDMA_DCBX_STATE_MASK)) { 2668 + pr_info("%s ocrdma%d DCBX is disabled\n", 2669 + dev_name(&dev->nic_info.pdev->dev), dev->id); 2670 + goto out; 2671 + } 2672 + 2673 + if (!ocrdma_is_enabled_and_synced(dcbxcfg->pfc_state)) { 2674 + pr_info("%s ocrdma%d priority flow control(%s) is %s%s\n", 2675 + dev_name(&dev->nic_info.pdev->dev), dev->id, 2676 + (ptype > 0 ? "operational" : "admin"), 2677 + (dcbxcfg->pfc_state & OCRDMA_STATE_FLAG_ENABLED) ? 2678 + "enabled" : "disabled", 2679 + (dcbxcfg->pfc_state & OCRDMA_STATE_FLAG_SYNC) ? 2680 + "" : ", not sync'ed"); 2681 + goto out; 2682 + } else { 2683 + pr_info("%s ocrdma%d priority flow control is enabled and sync'ed\n", 2684 + dev_name(&dev->nic_info.pdev->dev), dev->id); 2685 + } 2686 + 2687 + ventry_cnt = (dcbxcfg->tcv_aev_opv_st >> 2688 + OCRDMA_DCBX_APP_ENTRY_SHIFT) 2689 + & OCRDMA_DCBX_STATE_MASK; 2690 + 2691 + for (indx = 0; indx < ventry_cnt; indx++) { 2692 + app_param = &dcbxcfg->app_param[indx]; 2693 + valid = (app_param->valid_proto_app >> 2694 + OCRDMA_APP_PARAM_VALID_SHIFT) 2695 + & OCRDMA_APP_PARAM_VALID_MASK; 2696 + proto_sel = (app_param->valid_proto_app 2697 + >> OCRDMA_APP_PARAM_PROTO_SEL_SHIFT) 2698 + & OCRDMA_APP_PARAM_PROTO_SEL_MASK; 2699 + proto = app_param->valid_proto_app & 2700 + OCRDMA_APP_PARAM_APP_PROTO_MASK; 2701 + 2702 + if ( 2703 + valid && proto == OCRDMA_APP_PROTO_ROCE && 2704 + proto_sel == OCRDMA_PROTO_SELECT_L2) { 2705 + for (slindx = 0; slindx < 2706 + OCRDMA_MAX_SERVICE_LEVEL_INDEX; slindx++) { 2707 + app_prio = ocrdma_get_app_prio( 2708 + (u8 *)app_param->app_prio, 2709 + slindx); 2710 + pfc_prio = ocrdma_get_pfc_prio( 2711 + (u8 *)dcbxcfg->pfc_prio, 2712 + slindx); 2713 + 2714 + if (app_prio && pfc_prio) { 2715 + *srvc_lvl = slindx; 2716 + status = 0; 2717 + goto out; 2718 + } 2719 + } 2720 + if (slindx == OCRDMA_MAX_SERVICE_LEVEL_INDEX) { 2721 + pr_info("%s ocrdma%d application priority not set for 0x%x protocol\n", 2722 + dev_name(&dev->nic_info.pdev->dev), 2723 + dev->id, proto); 2724 + } 2725 + } 2726 + } 2727 + 2728 + out: 2729 + return status; 2730 + } 2731 + 2732 + void ocrdma_init_service_level(struct ocrdma_dev *dev) 2733 + { 2734 + int status = 0, indx; 2735 + struct ocrdma_dcbx_cfg dcbxcfg; 2736 + u8 srvc_lvl = OCRDMA_DEFAULT_SERVICE_LEVEL; 2737 + int ptype = OCRDMA_PARAMETER_TYPE_OPER; 2738 + 2739 + for (indx = 0; indx < 2; indx++) { 2740 + status = ocrdma_mbx_get_dcbx_config(dev, ptype, &dcbxcfg); 2741 + if (status) { 2742 + pr_err("%s(): status=%d\n", __func__, status); 2743 + ptype = OCRDMA_PARAMETER_TYPE_ADMIN; 2744 + continue; 2745 + } 2746 + 2747 + status = ocrdma_parse_dcbxcfg_rsp(dev, ptype, 2748 + &dcbxcfg, &srvc_lvl); 2749 + if (status) { 2750 + ptype = OCRDMA_PARAMETER_TYPE_ADMIN; 2751 + continue; 2752 + } 2753 + 2754 + break; 2755 + } 2756 + 2757 + if (status) 2758 + pr_info("%s ocrdma%d service level default\n", 2759 + dev_name(&dev->nic_info.pdev->dev), dev->id); 2760 + else 2761 + pr_info("%s ocrdma%d service level %d\n", 2762 + dev_name(&dev->nic_info.pdev->dev), dev->id, 2763 + srvc_lvl); 2764 + 2765 + dev->pfc_state = ocrdma_is_enabled_and_synced(dcbxcfg.pfc_state); 2766 + dev->sl = srvc_lvl; 2767 + } 2768 + 2636 2769 int ocrdma_alloc_av(struct ocrdma_dev *dev, struct ocrdma_ah *ah) 2637 2770 { 2638 2771 int i; ··· 2900 2709 goto conf_err; 2901 2710 status = ocrdma_mbx_get_phy_info(dev); 2902 2711 if (status) 2903 - goto conf_err; 2712 + goto info_attrb_err; 2904 2713 status = ocrdma_mbx_get_ctrl_attribs(dev); 2905 2714 if (status) 2906 - goto conf_err; 2715 + goto info_attrb_err; 2907 2716 2908 2717 return 0; 2909 2718 2719 + info_attrb_err: 2720 + ocrdma_mbx_delete_ah_tbl(dev); 2910 2721 conf_err: 2911 2722 ocrdma_destroy_mq(dev); 2912 2723 mq_err:
+2
drivers/infiniband/hw/ocrdma/ocrdma_hw.h
··· 135 135 136 136 int ocrdma_mbx_rdma_stats(struct ocrdma_dev *, bool reset); 137 137 char *port_speed_string(struct ocrdma_dev *dev); 138 + void ocrdma_init_service_level(struct ocrdma_dev *); 139 + 138 140 #endif /* __OCRDMA_HW_H__ */
+81 -2
drivers/infiniband/hw/ocrdma/ocrdma_main.c
··· 324 324 if (!dev->qp_tbl) 325 325 goto alloc_err; 326 326 } 327 + 328 + dev->stag_arr = kzalloc(sizeof(u64) * OCRDMA_MAX_STAG, GFP_KERNEL); 329 + if (dev->stag_arr == NULL) 330 + goto alloc_err; 331 + 327 332 spin_lock_init(&dev->av_tbl.lock); 328 333 spin_lock_init(&dev->flush_q_lock); 329 334 return 0; ··· 339 334 340 335 static void ocrdma_free_resources(struct ocrdma_dev *dev) 341 336 { 337 + kfree(dev->stag_arr); 342 338 kfree(dev->qp_tbl); 343 339 kfree(dev->cq_tbl); 344 340 kfree(dev->sgid_tbl); ··· 359 353 { 360 354 struct ocrdma_dev *dev = dev_get_drvdata(device); 361 355 362 - return scnprintf(buf, PAGE_SIZE, "%s", &dev->attr.fw_ver[0]); 356 + return scnprintf(buf, PAGE_SIZE, "%s\n", &dev->attr.fw_ver[0]); 357 + } 358 + 359 + static ssize_t show_hca_type(struct device *device, 360 + struct device_attribute *attr, char *buf) 361 + { 362 + struct ocrdma_dev *dev = dev_get_drvdata(device); 363 + 364 + return scnprintf(buf, PAGE_SIZE, "%s\n", &dev->model_number[0]); 363 365 } 364 366 365 367 static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 366 368 static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 369 + static DEVICE_ATTR(hca_type, S_IRUGO, show_hca_type, NULL); 367 370 368 371 static struct device_attribute *ocrdma_attributes[] = { 369 372 &dev_attr_hw_rev, 370 - &dev_attr_fw_ver 373 + &dev_attr_fw_ver, 374 + &dev_attr_hca_type 371 375 }; 372 376 373 377 static void ocrdma_remove_sysfiles(struct ocrdma_dev *dev) ··· 386 370 387 371 for (i = 0; i < ARRAY_SIZE(ocrdma_attributes); i++) 388 372 device_remove_file(&dev->ibdev.dev, ocrdma_attributes[i]); 373 + } 374 + 375 + static void ocrdma_init_ipv4_gids(struct ocrdma_dev *dev, 376 + struct net_device *net) 377 + { 378 + struct in_device *in_dev; 379 + union ib_gid gid; 380 + in_dev = in_dev_get(net); 381 + if (in_dev) { 382 + for_ifa(in_dev) { 383 + ipv6_addr_set_v4mapped(ifa->ifa_address, 384 + (struct in6_addr *)&gid); 385 + ocrdma_add_sgid(dev, &gid); 386 + } 387 + endfor_ifa(in_dev); 388 + in_dev_put(in_dev); 389 + } 390 + } 391 + 392 + static void ocrdma_init_ipv6_gids(struct ocrdma_dev *dev, 393 + struct net_device *net) 394 + { 395 + #if IS_ENABLED(CONFIG_IPV6) 396 + struct inet6_dev *in6_dev; 397 + union ib_gid *pgid; 398 + struct inet6_ifaddr *ifp; 399 + in6_dev = in6_dev_get(net); 400 + if (in6_dev) { 401 + read_lock_bh(&in6_dev->lock); 402 + list_for_each_entry(ifp, &in6_dev->addr_list, if_list) { 403 + pgid = (union ib_gid *)&ifp->addr; 404 + ocrdma_add_sgid(dev, pgid); 405 + } 406 + read_unlock_bh(&in6_dev->lock); 407 + in6_dev_put(in6_dev); 408 + } 409 + #endif 410 + } 411 + 412 + static void ocrdma_init_gid_table(struct ocrdma_dev *dev) 413 + { 414 + struct net_device *net_dev; 415 + 416 + for_each_netdev(&init_net, net_dev) { 417 + struct net_device *real_dev = rdma_vlan_dev_real_dev(net_dev) ? 418 + rdma_vlan_dev_real_dev(net_dev) : net_dev; 419 + 420 + if (real_dev == dev->nic_info.netdev) { 421 + ocrdma_init_ipv4_gids(dev, net_dev); 422 + ocrdma_init_ipv6_gids(dev, net_dev); 423 + } 424 + } 389 425 } 390 426 391 427 static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) ··· 467 399 if (status) 468 400 goto alloc_err; 469 401 402 + ocrdma_init_service_level(dev); 403 + ocrdma_init_gid_table(dev); 470 404 status = ocrdma_register_device(dev); 471 405 if (status) 472 406 goto alloc_err; ··· 578 508 return 0; 579 509 } 580 510 511 + static void ocrdma_shutdown(struct ocrdma_dev *dev) 512 + { 513 + ocrdma_close(dev); 514 + ocrdma_remove(dev); 515 + } 516 + 581 517 /* event handling via NIC driver ensures that all the NIC specific 582 518 * initialization done before RoCE driver notifies 583 519 * event to stack. ··· 596 520 break; 597 521 case BE_DEV_DOWN: 598 522 ocrdma_close(dev); 523 + break; 524 + case BE_DEV_SHUTDOWN: 525 + ocrdma_shutdown(dev); 599 526 break; 600 527 } 601 528 }
+218 -67
drivers/infiniband/hw/ocrdma/ocrdma_sli.h
··· 44 44 #define OCRDMA_SUBSYS_ROCE 10 45 45 enum { 46 46 OCRDMA_CMD_QUERY_CONFIG = 1, 47 - OCRDMA_CMD_ALLOC_PD, 48 - OCRDMA_CMD_DEALLOC_PD, 47 + OCRDMA_CMD_ALLOC_PD = 2, 48 + OCRDMA_CMD_DEALLOC_PD = 3, 49 49 50 - OCRDMA_CMD_CREATE_AH_TBL, 51 - OCRDMA_CMD_DELETE_AH_TBL, 50 + OCRDMA_CMD_CREATE_AH_TBL = 4, 51 + OCRDMA_CMD_DELETE_AH_TBL = 5, 52 52 53 - OCRDMA_CMD_CREATE_QP, 54 - OCRDMA_CMD_QUERY_QP, 55 - OCRDMA_CMD_MODIFY_QP, 56 - OCRDMA_CMD_DELETE_QP, 53 + OCRDMA_CMD_CREATE_QP = 6, 54 + OCRDMA_CMD_QUERY_QP = 7, 55 + OCRDMA_CMD_MODIFY_QP = 8 , 56 + OCRDMA_CMD_DELETE_QP = 9, 57 57 58 - OCRDMA_CMD_RSVD1, 59 - OCRDMA_CMD_ALLOC_LKEY, 60 - OCRDMA_CMD_DEALLOC_LKEY, 61 - OCRDMA_CMD_REGISTER_NSMR, 62 - OCRDMA_CMD_REREGISTER_NSMR, 63 - OCRDMA_CMD_REGISTER_NSMR_CONT, 64 - OCRDMA_CMD_QUERY_NSMR, 65 - OCRDMA_CMD_ALLOC_MW, 66 - OCRDMA_CMD_QUERY_MW, 58 + OCRDMA_CMD_RSVD1 = 10, 59 + OCRDMA_CMD_ALLOC_LKEY = 11, 60 + OCRDMA_CMD_DEALLOC_LKEY = 12, 61 + OCRDMA_CMD_REGISTER_NSMR = 13, 62 + OCRDMA_CMD_REREGISTER_NSMR = 14, 63 + OCRDMA_CMD_REGISTER_NSMR_CONT = 15, 64 + OCRDMA_CMD_QUERY_NSMR = 16, 65 + OCRDMA_CMD_ALLOC_MW = 17, 66 + OCRDMA_CMD_QUERY_MW = 18, 67 67 68 - OCRDMA_CMD_CREATE_SRQ, 69 - OCRDMA_CMD_QUERY_SRQ, 70 - OCRDMA_CMD_MODIFY_SRQ, 71 - OCRDMA_CMD_DELETE_SRQ, 68 + OCRDMA_CMD_CREATE_SRQ = 19, 69 + OCRDMA_CMD_QUERY_SRQ = 20, 70 + OCRDMA_CMD_MODIFY_SRQ = 21, 71 + OCRDMA_CMD_DELETE_SRQ = 22, 72 72 73 - OCRDMA_CMD_ATTACH_MCAST, 74 - OCRDMA_CMD_DETACH_MCAST, 75 - OCRDMA_CMD_GET_RDMA_STATS, 73 + OCRDMA_CMD_ATTACH_MCAST = 23, 74 + OCRDMA_CMD_DETACH_MCAST = 24, 75 + 76 + OCRDMA_CMD_CREATE_RBQ = 25, 77 + OCRDMA_CMD_DESTROY_RBQ = 26, 78 + 79 + OCRDMA_CMD_GET_RDMA_STATS = 27, 76 80 77 81 OCRDMA_CMD_MAX 78 82 }; ··· 107 103 108 104 #define OCRDMA_MAX_QP 2048 109 105 #define OCRDMA_MAX_CQ 2048 110 - #define OCRDMA_MAX_STAG 8192 106 + #define OCRDMA_MAX_STAG 16384 111 107 112 108 enum { 113 109 OCRDMA_DB_RQ_OFFSET = 0xE0, ··· 426 422 427 423 #define OCRDMA_ASYNC_RDMA_EVE_CODE 0x14 428 424 #define OCRDMA_ASYNC_GRP5_EVE_CODE 0x5 429 - #define OCRDMA_ASYNC_EVENT_PVID_STATE 0x3 425 + 426 + enum ocrdma_async_grp5_events { 427 + OCRDMA_ASYNC_EVENT_QOS_VALUE = 0x01, 428 + OCRDMA_ASYNC_EVENT_COS_VALUE = 0x02, 429 + OCRDMA_ASYNC_EVENT_PVID_STATE = 0x03 430 + }; 430 431 431 432 enum OCRDMA_ASYNC_EVENT_TYPE { 432 433 OCRDMA_CQ_ERROR = 0x00, ··· 534 525 u32 max_ird_ord_per_qp; 535 526 u32 max_shared_ird_ord; 536 527 u32 max_mr; 537 - u32 max_mr_size_lo; 538 528 u32 max_mr_size_hi; 529 + u32 max_mr_size_lo; 539 530 u32 max_num_mr_pbl; 540 531 u32 max_mw; 541 532 u32 max_fmr; ··· 589 580 OCRDMA_FN_MODE_RDMA = 0x4 590 581 }; 591 582 583 + enum { 584 + OCRDMA_IF_TYPE_MASK = 0xFFFF0000, 585 + OCRDMA_IF_TYPE_SHIFT = 0x10, 586 + OCRDMA_PHY_TYPE_MASK = 0x0000FFFF, 587 + OCRDMA_FUTURE_DETAILS_MASK = 0xFFFF0000, 588 + OCRDMA_FUTURE_DETAILS_SHIFT = 0x10, 589 + OCRDMA_EX_PHY_DETAILS_MASK = 0x0000FFFF, 590 + OCRDMA_FSPEED_SUPP_MASK = 0xFFFF0000, 591 + OCRDMA_FSPEED_SUPP_SHIFT = 0x10, 592 + OCRDMA_ASPEED_SUPP_MASK = 0x0000FFFF 593 + }; 594 + 592 595 struct ocrdma_get_phy_info_rsp { 593 596 struct ocrdma_mqe_hdr hdr; 594 597 struct ocrdma_mbx_rsp rsp; 595 598 596 - u16 phy_type; 597 - u16 interface_type; 599 + u32 ityp_ptyp; 598 600 u32 misc_params; 599 - u16 ext_phy_details; 600 - u16 rsvd; 601 - u16 auto_speeds_supported; 602 - u16 fixed_speeds_supported; 601 + u32 ftrdtl_exphydtl; 602 + u32 fspeed_aspeed; 603 603 u32 future_use[2]; 604 604 }; 605 605 ··· 621 603 OCRDMA_PHY_SPEED_40GBPS = 0x20 622 604 }; 623 605 606 + enum { 607 + OCRDMA_PORT_NUM_MASK = 0x3F, 608 + OCRDMA_PT_MASK = 0xC0, 609 + OCRDMA_PT_SHIFT = 0x6, 610 + OCRDMA_LINK_DUP_MASK = 0x0000FF00, 611 + OCRDMA_LINK_DUP_SHIFT = 0x8, 612 + OCRDMA_PHY_PS_MASK = 0x00FF0000, 613 + OCRDMA_PHY_PS_SHIFT = 0x10, 614 + OCRDMA_PHY_PFLT_MASK = 0xFF000000, 615 + OCRDMA_PHY_PFLT_SHIFT = 0x18, 616 + OCRDMA_QOS_LNKSP_MASK = 0xFFFF0000, 617 + OCRDMA_QOS_LNKSP_SHIFT = 0x10, 618 + OCRDMA_LLST_MASK = 0xFF, 619 + OCRDMA_PLFC_MASK = 0x00000400, 620 + OCRDMA_PLFC_SHIFT = 0x8, 621 + OCRDMA_PLRFC_MASK = 0x00000200, 622 + OCRDMA_PLRFC_SHIFT = 0x8, 623 + OCRDMA_PLTFC_MASK = 0x00000100, 624 + OCRDMA_PLTFC_SHIFT = 0x8 625 + }; 624 626 625 627 struct ocrdma_get_link_speed_rsp { 626 628 struct ocrdma_mqe_hdr hdr; 627 629 struct ocrdma_mbx_rsp rsp; 628 630 629 - u8 pt_port_num; 630 - u8 link_duplex; 631 - u8 phys_port_speed; 632 - u8 phys_port_fault; 633 - u16 rsvd1; 634 - u16 qos_lnk_speed; 635 - u8 logical_lnk_status; 636 - u8 rsvd2[3]; 631 + u32 pflt_pps_ld_pnum; 632 + u32 qos_lsp; 633 + u32 res_lls; 637 634 }; 638 635 639 636 enum { ··· 699 666 u32 pgsz_pgcnt; 700 667 u32 ev_cnt_flags; 701 668 u32 eqn; 702 - u16 cqe_count; 703 - u16 pd_id; 669 + u32 pdid_cqecnt; 704 670 u32 rsvd6; 705 671 struct ocrdma_pa pa[OCRDMA_CREATE_CQ_MAX_PAGES]; 706 672 }; ··· 707 675 struct ocrdma_create_cq { 708 676 struct ocrdma_mqe_hdr hdr; 709 677 struct ocrdma_create_cq_cmd cmd; 678 + }; 679 + 680 + enum { 681 + OCRDMA_CREATE_CQ_CMD_PDID_SHIFT = 0x10 710 682 }; 711 683 712 684 enum { ··· 1267 1231 1268 1232 enum { 1269 1233 OCRDMA_ALLOC_PD_ENABLE_DPP = BIT(16), 1270 - OCRDMA_PD_MAX_DPP_ENABLED_QP = 8, 1271 1234 OCRDMA_DPP_PAGE_SIZE = 4096 1272 1235 }; 1273 1236 ··· 1931 1896 struct ocrdma_rx_dbg_stats rx_dbg_stats; 1932 1897 } __packed; 1933 1898 1899 + enum { 1900 + OCRDMA_HBA_ATTRB_EPROM_VER_LO_MASK = 0xFF, 1901 + OCRDMA_HBA_ATTRB_EPROM_VER_HI_MASK = 0xFF00, 1902 + OCRDMA_HBA_ATTRB_EPROM_VER_HI_SHIFT = 0x08, 1903 + OCRDMA_HBA_ATTRB_CDBLEN_MASK = 0xFFFF, 1904 + OCRDMA_HBA_ATTRB_ASIC_REV_MASK = 0xFF0000, 1905 + OCRDMA_HBA_ATTRB_ASIC_REV_SHIFT = 0x10, 1906 + OCRDMA_HBA_ATTRB_GUID0_MASK = 0xFF000000, 1907 + OCRDMA_HBA_ATTRB_GUID0_SHIFT = 0x18, 1908 + OCRDMA_HBA_ATTRB_GUID13_MASK = 0xFF, 1909 + OCRDMA_HBA_ATTRB_GUID14_MASK = 0xFF00, 1910 + OCRDMA_HBA_ATTRB_GUID14_SHIFT = 0x08, 1911 + OCRDMA_HBA_ATTRB_GUID15_MASK = 0xFF0000, 1912 + OCRDMA_HBA_ATTRB_GUID15_SHIFT = 0x10, 1913 + OCRDMA_HBA_ATTRB_PCNT_MASK = 0xFF000000, 1914 + OCRDMA_HBA_ATTRB_PCNT_SHIFT = 0x18, 1915 + OCRDMA_HBA_ATTRB_LDTOUT_MASK = 0xFFFF, 1916 + OCRDMA_HBA_ATTRB_ISCSI_VER_MASK = 0xFF0000, 1917 + OCRDMA_HBA_ATTRB_ISCSI_VER_SHIFT = 0x10, 1918 + OCRDMA_HBA_ATTRB_MFUNC_DEV_MASK = 0xFF000000, 1919 + OCRDMA_HBA_ATTRB_MFUNC_DEV_SHIFT = 0x18, 1920 + OCRDMA_HBA_ATTRB_CV_MASK = 0xFF, 1921 + OCRDMA_HBA_ATTRB_HBA_ST_MASK = 0xFF00, 1922 + OCRDMA_HBA_ATTRB_HBA_ST_SHIFT = 0x08, 1923 + OCRDMA_HBA_ATTRB_MAX_DOMS_MASK = 0xFF0000, 1924 + OCRDMA_HBA_ATTRB_MAX_DOMS_SHIFT = 0x10, 1925 + OCRDMA_HBA_ATTRB_PTNUM_MASK = 0x3F000000, 1926 + OCRDMA_HBA_ATTRB_PTNUM_SHIFT = 0x18, 1927 + OCRDMA_HBA_ATTRB_PT_MASK = 0xC0000000, 1928 + OCRDMA_HBA_ATTRB_PT_SHIFT = 0x1E, 1929 + OCRDMA_HBA_ATTRB_ISCSI_FET_MASK = 0xFF, 1930 + OCRDMA_HBA_ATTRB_ASIC_GEN_MASK = 0xFF00, 1931 + OCRDMA_HBA_ATTRB_ASIC_GEN_SHIFT = 0x08, 1932 + OCRDMA_HBA_ATTRB_PCI_VID_MASK = 0xFFFF, 1933 + OCRDMA_HBA_ATTRB_PCI_DID_MASK = 0xFFFF0000, 1934 + OCRDMA_HBA_ATTRB_PCI_DID_SHIFT = 0x10, 1935 + OCRDMA_HBA_ATTRB_PCI_SVID_MASK = 0xFFFF, 1936 + OCRDMA_HBA_ATTRB_PCI_SSID_MASK = 0xFFFF0000, 1937 + OCRDMA_HBA_ATTRB_PCI_SSID_SHIFT = 0x10, 1938 + OCRDMA_HBA_ATTRB_PCI_BUSNUM_MASK = 0xFF, 1939 + OCRDMA_HBA_ATTRB_PCI_DEVNUM_MASK = 0xFF00, 1940 + OCRDMA_HBA_ATTRB_PCI_DEVNUM_SHIFT = 0x08, 1941 + OCRDMA_HBA_ATTRB_PCI_FUNCNUM_MASK = 0xFF0000, 1942 + OCRDMA_HBA_ATTRB_PCI_FUNCNUM_SHIFT = 0x10, 1943 + OCRDMA_HBA_ATTRB_IF_TYPE_MASK = 0xFF000000, 1944 + OCRDMA_HBA_ATTRB_IF_TYPE_SHIFT = 0x18, 1945 + OCRDMA_HBA_ATTRB_NETFIL_MASK =0xFF 1946 + }; 1934 1947 1935 1948 struct mgmt_hba_attribs { 1936 1949 u8 flashrom_version_string[32]; 1937 1950 u8 manufacturer_name[32]; 1938 1951 u32 supported_modes; 1939 - u32 rsvd0[3]; 1952 + u32 rsvd_eprom_verhi_verlo; 1953 + u32 mbx_ds_ver; 1954 + u32 epfw_ds_ver; 1940 1955 u8 ncsi_ver_string[12]; 1941 1956 u32 default_extended_timeout; 1942 1957 u8 controller_model_number[32]; ··· 1999 1914 u8 driver_version_string[32]; 2000 1915 u8 fw_on_flash_version_string[32]; 2001 1916 u32 functionalities_supported; 2002 - u16 max_cdblength; 2003 - u8 asic_revision; 2004 - u8 generational_guid[16]; 2005 - u8 hba_port_count; 2006 - u16 default_link_down_timeout; 2007 - u8 iscsi_ver_min_max; 2008 - u8 multifunction_device; 2009 - u8 cache_valid; 2010 - u8 hba_status; 2011 - u8 max_domains_supported; 2012 - u8 phy_port; 1917 + u32 guid0_asicrev_cdblen; 1918 + u8 generational_guid[12]; 1919 + u32 portcnt_guid15; 1920 + u32 mfuncdev_iscsi_ldtout; 1921 + u32 ptpnum_maxdoms_hbast_cv; 2013 1922 u32 firmware_post_status; 2014 1923 u32 hba_mtu[8]; 2015 - u32 rsvd1[4]; 1924 + u32 res_asicgen_iscsi_feaures; 1925 + u32 rsvd1[3]; 2016 1926 }; 2017 1927 2018 1928 struct mgmt_controller_attrib { 2019 1929 struct mgmt_hba_attribs hba_attribs; 2020 - u16 pci_vendor_id; 2021 - u16 pci_device_id; 2022 - u16 pci_sub_vendor_id; 2023 - u16 pci_sub_system_id; 2024 - u8 pci_bus_number; 2025 - u8 pci_device_number; 2026 - u8 pci_function_number; 2027 - u8 interface_type; 2028 - u64 unique_identifier; 2029 - u32 rsvd0[5]; 1930 + u32 pci_did_vid; 1931 + u32 pci_ssid_svid; 1932 + u32 ityp_fnum_devnum_bnum; 1933 + u32 uid_hi; 1934 + u32 uid_lo; 1935 + u32 res_nnetfil; 1936 + u32 rsvd0[4]; 2030 1937 }; 2031 1938 2032 1939 struct ocrdma_get_ctrl_attribs_rsp { ··· 2026 1949 struct mgmt_controller_attrib ctrl_attribs; 2027 1950 }; 2028 1951 1952 + #define OCRDMA_SUBSYS_DCBX 0x10 1953 + 1954 + enum OCRDMA_DCBX_OPCODE { 1955 + OCRDMA_CMD_GET_DCBX_CONFIG = 0x01 1956 + }; 1957 + 1958 + enum OCRDMA_DCBX_PARAM_TYPE { 1959 + OCRDMA_PARAMETER_TYPE_ADMIN = 0x00, 1960 + OCRDMA_PARAMETER_TYPE_OPER = 0x01, 1961 + OCRDMA_PARAMETER_TYPE_PEER = 0x02 1962 + }; 1963 + 1964 + enum OCRDMA_DCBX_APP_PROTO { 1965 + OCRDMA_APP_PROTO_ROCE = 0x8915 1966 + }; 1967 + 1968 + enum OCRDMA_DCBX_PROTO { 1969 + OCRDMA_PROTO_SELECT_L2 = 0x00, 1970 + OCRDMA_PROTO_SELECT_L4 = 0x01 1971 + }; 1972 + 1973 + enum OCRDMA_DCBX_APP_PARAM { 1974 + OCRDMA_APP_PARAM_APP_PROTO_MASK = 0xFFFF, 1975 + OCRDMA_APP_PARAM_PROTO_SEL_MASK = 0xFF, 1976 + OCRDMA_APP_PARAM_PROTO_SEL_SHIFT = 0x10, 1977 + OCRDMA_APP_PARAM_VALID_MASK = 0xFF, 1978 + OCRDMA_APP_PARAM_VALID_SHIFT = 0x18 1979 + }; 1980 + 1981 + enum OCRDMA_DCBX_STATE_FLAGS { 1982 + OCRDMA_STATE_FLAG_ENABLED = 0x01, 1983 + OCRDMA_STATE_FLAG_ADDVERTISED = 0x02, 1984 + OCRDMA_STATE_FLAG_WILLING = 0x04, 1985 + OCRDMA_STATE_FLAG_SYNC = 0x08, 1986 + OCRDMA_STATE_FLAG_UNSUPPORTED = 0x40000000, 1987 + OCRDMA_STATE_FLAG_NEG_FAILD = 0x80000000 1988 + }; 1989 + 1990 + enum OCRDMA_TCV_AEV_OPV_ST { 1991 + OCRDMA_DCBX_TC_SUPPORT_MASK = 0xFF, 1992 + OCRDMA_DCBX_TC_SUPPORT_SHIFT = 0x18, 1993 + OCRDMA_DCBX_APP_ENTRY_SHIFT = 0x10, 1994 + OCRDMA_DCBX_OP_PARAM_SHIFT = 0x08, 1995 + OCRDMA_DCBX_STATE_MASK = 0xFF 1996 + }; 1997 + 1998 + struct ocrdma_app_parameter { 1999 + u32 valid_proto_app; 2000 + u32 oui; 2001 + u32 app_prio[2]; 2002 + }; 2003 + 2004 + struct ocrdma_dcbx_cfg { 2005 + u32 tcv_aev_opv_st; 2006 + u32 tc_state; 2007 + u32 pfc_state; 2008 + u32 qcn_state; 2009 + u32 appl_state; 2010 + u32 ll_state; 2011 + u32 tc_bw[2]; 2012 + u32 tc_prio[8]; 2013 + u32 pfc_prio[2]; 2014 + struct ocrdma_app_parameter app_param[15]; 2015 + }; 2016 + 2017 + struct ocrdma_get_dcbx_cfg_req { 2018 + struct ocrdma_mbx_hdr hdr; 2019 + u32 param_type; 2020 + } __packed; 2021 + 2022 + struct ocrdma_get_dcbx_cfg_rsp { 2023 + struct ocrdma_mbx_rsp hdr; 2024 + struct ocrdma_dcbx_cfg cfg; 2025 + } __packed; 2029 2026 2030 2027 #endif /* __OCRDMA_SLI_H__ */
+32 -4
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
··· 69 69 memcpy(&attr->fw_ver, &dev->attr.fw_ver[0], 70 70 min(sizeof(dev->attr.fw_ver), sizeof(attr->fw_ver))); 71 71 ocrdma_get_guid(dev, (u8 *)&attr->sys_image_guid); 72 - attr->max_mr_size = ~0ull; 72 + attr->max_mr_size = dev->attr.max_mr_size; 73 73 attr->page_size_cap = 0xffff000; 74 74 attr->vendor_id = dev->nic_info.pdev->vendor; 75 75 attr->vendor_part_id = dev->nic_info.pdev->device; 76 - attr->hw_ver = 0; 76 + attr->hw_ver = dev->asic_id; 77 77 attr->max_qp = dev->attr.max_qp; 78 78 attr->max_ah = OCRDMA_MAX_AH; 79 79 attr->max_qp_wr = dev->attr.max_wqe; ··· 268 268 pd->dpp_enabled = 269 269 ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R; 270 270 pd->num_dpp_qp = 271 - pd->dpp_enabled ? OCRDMA_PD_MAX_DPP_ENABLED_QP : 0; 271 + pd->dpp_enabled ? (dev->nic_info.db_page_size / 272 + dev->attr.wqe_size) : 0; 272 273 } 273 274 274 275 retry: ··· 329 328 struct ocrdma_pd *pd = uctx->cntxt_pd; 330 329 struct ocrdma_dev *dev = get_ocrdma_dev(pd->ibpd.device); 331 330 332 - BUG_ON(uctx->pd_in_use); 331 + if (uctx->pd_in_use) { 332 + pr_err("%s(%d) Freeing in use pdid=0x%x.\n", 333 + __func__, dev->id, pd->id); 334 + } 333 335 uctx->cntxt_pd = NULL; 334 336 status = _ocrdma_dealloc_pd(dev, pd); 335 337 return status; ··· 847 843 if (mr->umem) 848 844 ib_umem_release(mr->umem); 849 845 kfree(mr); 846 + 847 + /* Don't stop cleanup, in case FW is unresponsive */ 848 + if (dev->mqe_ctx.fw_error_state) { 849 + status = 0; 850 + pr_err("%s(%d) fw not responding.\n", 851 + __func__, dev->id); 852 + } 850 853 return status; 851 854 } 852 855 ··· 2065 2054 } 2066 2055 2067 2056 while (wr) { 2057 + if (qp->qp_type == IB_QPT_UD && 2058 + (wr->opcode != IB_WR_SEND && 2059 + wr->opcode != IB_WR_SEND_WITH_IMM)) { 2060 + *bad_wr = wr; 2061 + status = -EINVAL; 2062 + break; 2063 + } 2068 2064 if (ocrdma_hwq_free_cnt(&qp->sq) == 0 || 2069 2065 wr->num_sge > qp->sq.max_sges) { 2070 2066 *bad_wr = wr; ··· 2506 2488 *stop = true; 2507 2489 expand = false; 2508 2490 } 2491 + } else if (is_hw_sq_empty(qp)) { 2492 + /* Do nothing */ 2493 + expand = false; 2494 + *polled = false; 2495 + *stop = false; 2509 2496 } else { 2510 2497 *polled = true; 2511 2498 expand = ocrdma_update_err_scqe(ibwc, cqe, qp, status); ··· 2616 2593 *stop = true; 2617 2594 expand = false; 2618 2595 } 2596 + } else if (is_hw_rq_empty(qp)) { 2597 + /* Do nothing */ 2598 + expand = false; 2599 + *polled = false; 2600 + *stop = false; 2619 2601 } else { 2620 2602 *polled = true; 2621 2603 expand = ocrdma_update_err_rcqe(ibwc, cqe, qp, status);
+1 -1
drivers/infiniband/hw/qib/qib_mad.c
··· 2476 2476 ibp = &dd->pport[p].ibport_data; 2477 2477 agent = ib_register_mad_agent(&dev->ibdev, p + 1, IB_QPT_SMI, 2478 2478 NULL, 0, send_handler, 2479 - NULL, NULL); 2479 + NULL, NULL, 0); 2480 2480 if (IS_ERR(agent)) { 2481 2481 ret = PTR_ERR(agent); 2482 2482 goto err;
+3 -5
drivers/infiniband/ulp/ipoib/ipoib.h
··· 86 86 IPOIB_FLAG_INITIALIZED = 1, 87 87 IPOIB_FLAG_ADMIN_UP = 2, 88 88 IPOIB_PKEY_ASSIGNED = 3, 89 - IPOIB_PKEY_STOP = 4, 90 89 IPOIB_FLAG_SUBINTERFACE = 5, 91 90 IPOIB_MCAST_RUN = 6, 92 91 IPOIB_STOP_REAPER = 7, ··· 311 312 struct list_head multicast_list; 312 313 struct rb_root multicast_tree; 313 314 314 - struct delayed_work pkey_poll_task; 315 315 struct delayed_work mcast_task; 316 316 struct work_struct carrier_on_task; 317 317 struct work_struct flush_light; ··· 471 473 void ipoib_pkey_event(struct work_struct *work); 472 474 void ipoib_ib_dev_cleanup(struct net_device *dev); 473 475 474 - int ipoib_ib_dev_open(struct net_device *dev); 476 + int ipoib_ib_dev_open(struct net_device *dev, int flush); 475 477 int ipoib_ib_dev_up(struct net_device *dev); 476 478 int ipoib_ib_dev_down(struct net_device *dev, int flush); 477 479 int ipoib_ib_dev_stop(struct net_device *dev, int flush); 480 + void ipoib_pkey_dev_check_presence(struct net_device *dev); 478 481 479 482 int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 480 483 void ipoib_dev_cleanup(struct net_device *dev); ··· 531 532 532 533 void ipoib_setup(struct net_device *dev); 533 534 534 - void ipoib_pkey_poll(struct work_struct *work); 535 - int ipoib_pkey_dev_delay_open(struct net_device *dev); 535 + void ipoib_pkey_open(struct ipoib_dev_priv *priv); 536 536 void ipoib_drain_cq(struct net_device *dev); 537 537 538 538 void ipoib_set_ethtool_ops(struct net_device *dev);
+2 -4
drivers/infiniband/ulp/ipoib/ipoib_fs.c
··· 281 281 { 282 282 struct ipoib_dev_priv *priv = netdev_priv(dev); 283 283 284 - if (priv->mcg_dentry) 285 - debugfs_remove(priv->mcg_dentry); 286 - if (priv->path_dentry) 287 - debugfs_remove(priv->path_dentry); 284 + debugfs_remove(priv->mcg_dentry); 285 + debugfs_remove(priv->path_dentry); 288 286 } 289 287 290 288 int ipoib_register_debugfs(void)
+46 -87
drivers/infiniband/ulp/ipoib/ipoib_ib.c
··· 664 664 drain_tx_cq((struct net_device *)ctx); 665 665 } 666 666 667 - int ipoib_ib_dev_open(struct net_device *dev) 667 + int ipoib_ib_dev_open(struct net_device *dev, int flush) 668 668 { 669 669 struct ipoib_dev_priv *priv = netdev_priv(dev); 670 670 int ret; 671 671 672 - if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &priv->pkey_index)) { 673 - ipoib_warn(priv, "P_Key 0x%04x not found\n", priv->pkey); 674 - clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 672 + ipoib_pkey_dev_check_presence(dev); 673 + 674 + if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { 675 + ipoib_warn(priv, "P_Key 0x%04x is %s\n", priv->pkey, 676 + (!(priv->pkey & 0x7fff) ? "Invalid" : "not found")); 675 677 return -1; 676 678 } 677 - set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 678 679 679 680 ret = ipoib_init_qp(dev); 680 681 if (ret) { ··· 706 705 dev_stop: 707 706 if (!test_and_set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) 708 707 napi_enable(&priv->napi); 709 - ipoib_ib_dev_stop(dev, 1); 708 + ipoib_ib_dev_stop(dev, flush); 710 709 return -1; 711 710 } 712 711 713 - static void ipoib_pkey_dev_check_presence(struct net_device *dev) 712 + void ipoib_pkey_dev_check_presence(struct net_device *dev) 714 713 { 715 714 struct ipoib_dev_priv *priv = netdev_priv(dev); 716 - u16 pkey_index = 0; 717 715 718 - if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) 716 + if (!(priv->pkey & 0x7fff) || 717 + ib_find_pkey(priv->ca, priv->port, priv->pkey, 718 + &priv->pkey_index)) 719 719 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 720 720 else 721 721 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); ··· 746 744 747 745 clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags); 748 746 netif_carrier_off(dev); 749 - 750 - /* Shutdown the P_Key thread if still active */ 751 - if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { 752 - mutex_lock(&pkey_mutex); 753 - set_bit(IPOIB_PKEY_STOP, &priv->flags); 754 - cancel_delayed_work_sync(&priv->pkey_poll_task); 755 - mutex_unlock(&pkey_mutex); 756 - } 757 747 758 748 ipoib_mcast_stop_thread(dev, flush); 759 749 ipoib_mcast_dev_flush(dev); ··· 918 924 (unsigned long) dev); 919 925 920 926 if (dev->flags & IFF_UP) { 921 - if (ipoib_ib_dev_open(dev)) { 927 + if (ipoib_ib_dev_open(dev, 1)) { 922 928 ipoib_transport_dev_cleanup(dev); 923 929 return -ENODEV; 924 930 } ··· 960 966 961 967 return 1; 962 968 } 969 + /* 970 + * returns 0 if pkey value was found in a different slot. 971 + */ 972 + static inline int update_child_pkey(struct ipoib_dev_priv *priv) 973 + { 974 + u16 old_index = priv->pkey_index; 975 + 976 + priv->pkey_index = 0; 977 + ipoib_pkey_dev_check_presence(priv->dev); 978 + 979 + if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags) && 980 + (old_index == priv->pkey_index)) 981 + return 1; 982 + return 0; 983 + } 963 984 964 985 static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, 965 986 enum ipoib_flush_level level) 966 987 { 967 988 struct ipoib_dev_priv *cpriv; 968 989 struct net_device *dev = priv->dev; 969 - u16 new_index; 970 990 int result; 971 991 972 992 down_read(&priv->vlan_rwsem); ··· 994 986 995 987 up_read(&priv->vlan_rwsem); 996 988 997 - if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) { 998 - /* for non-child devices must check/update the pkey value here */ 999 - if (level == IPOIB_FLUSH_HEAVY && 1000 - !test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) 1001 - update_parent_pkey(priv); 989 + if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) && 990 + level != IPOIB_FLUSH_HEAVY) { 1002 991 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); 1003 992 return; 1004 993 } 1005 994 1006 995 if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { 996 + /* interface is down. update pkey and leave. */ 997 + if (level == IPOIB_FLUSH_HEAVY) { 998 + if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) 999 + update_parent_pkey(priv); 1000 + else 1001 + update_child_pkey(priv); 1002 + } 1007 1003 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_ADMIN_UP not set.\n"); 1008 1004 return; 1009 1005 } ··· 1017 1005 * (parent) devices should always takes what present in pkey index 0 1018 1006 */ 1019 1007 if (test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { 1020 - if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { 1021 - clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 1022 - ipoib_ib_dev_down(dev, 0); 1023 - ipoib_ib_dev_stop(dev, 0); 1024 - if (ipoib_pkey_dev_delay_open(dev)) 1025 - return; 1026 - } 1027 - /* restart QP only if P_Key index is changed */ 1028 - if (test_and_set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags) && 1029 - new_index == priv->pkey_index) { 1008 + result = update_child_pkey(priv); 1009 + if (result) { 1010 + /* restart QP only if P_Key index is changed */ 1030 1011 ipoib_dbg(priv, "Not flushing - P_Key index not changed.\n"); 1031 1012 return; 1032 1013 } 1033 - priv->pkey_index = new_index; 1014 + 1034 1015 } else { 1035 1016 result = update_parent_pkey(priv); 1036 1017 /* restart QP only if P_Key value changed */ ··· 1043 1038 ipoib_ib_dev_down(dev, 0); 1044 1039 1045 1040 if (level == IPOIB_FLUSH_HEAVY) { 1046 - ipoib_ib_dev_stop(dev, 0); 1047 - ipoib_ib_dev_open(dev); 1041 + if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) 1042 + ipoib_ib_dev_stop(dev, 0); 1043 + if (ipoib_ib_dev_open(dev, 0) != 0) 1044 + return; 1045 + if (netif_queue_stopped(dev)) 1046 + netif_start_queue(dev); 1048 1047 } 1049 1048 1050 1049 /* ··· 1103 1094 ipoib_transport_dev_cleanup(dev); 1104 1095 } 1105 1096 1106 - /* 1107 - * Delayed P_Key Assigment Interim Support 1108 - * 1109 - * The following is initial implementation of delayed P_Key assigment 1110 - * mechanism. It is using the same approach implemented for the multicast 1111 - * group join. The single goal of this implementation is to quickly address 1112 - * Bug #2507. This implementation will probably be removed when the P_Key 1113 - * change async notification is available. 1114 - */ 1115 1097 1116 - void ipoib_pkey_poll(struct work_struct *work) 1117 - { 1118 - struct ipoib_dev_priv *priv = 1119 - container_of(work, struct ipoib_dev_priv, pkey_poll_task.work); 1120 - struct net_device *dev = priv->dev; 1121 - 1122 - ipoib_pkey_dev_check_presence(dev); 1123 - 1124 - if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) 1125 - ipoib_open(dev); 1126 - else { 1127 - mutex_lock(&pkey_mutex); 1128 - if (!test_bit(IPOIB_PKEY_STOP, &priv->flags)) 1129 - queue_delayed_work(ipoib_workqueue, 1130 - &priv->pkey_poll_task, 1131 - HZ); 1132 - mutex_unlock(&pkey_mutex); 1133 - } 1134 - } 1135 - 1136 - int ipoib_pkey_dev_delay_open(struct net_device *dev) 1137 - { 1138 - struct ipoib_dev_priv *priv = netdev_priv(dev); 1139 - 1140 - /* Look for the interface pkey value in the IB Port P_Key table and */ 1141 - /* set the interface pkey assigment flag */ 1142 - ipoib_pkey_dev_check_presence(dev); 1143 - 1144 - /* P_Key value not assigned yet - start polling */ 1145 - if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { 1146 - mutex_lock(&pkey_mutex); 1147 - clear_bit(IPOIB_PKEY_STOP, &priv->flags); 1148 - queue_delayed_work(ipoib_workqueue, 1149 - &priv->pkey_poll_task, 1150 - HZ); 1151 - mutex_unlock(&pkey_mutex); 1152 - return 1; 1153 - } 1154 - 1155 - return 0; 1156 - }
+4 -5
drivers/infiniband/ulp/ipoib/ipoib_main.c
··· 108 108 109 109 set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); 110 110 111 - if (ipoib_pkey_dev_delay_open(dev)) 112 - return 0; 113 - 114 - if (ipoib_ib_dev_open(dev)) 111 + if (ipoib_ib_dev_open(dev, 1)) { 112 + if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) 113 + return 0; 115 114 goto err_disable; 115 + } 116 116 117 117 if (ipoib_ib_dev_up(dev)) 118 118 goto err_stop; ··· 1379 1379 INIT_LIST_HEAD(&priv->dead_ahs); 1380 1380 INIT_LIST_HEAD(&priv->multicast_list); 1381 1381 1382 - INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll); 1383 1382 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task); 1384 1383 INIT_WORK(&priv->carrier_on_task, ipoib_mcast_carrier_on_task); 1385 1384 INIT_WORK(&priv->flush_light, ipoib_ib_dev_flush_light);
+31 -16
drivers/infiniband/ulp/iser/iscsi_iser.c
··· 596 596 struct iser_conn *ib_conn; 597 597 struct iscsi_endpoint *ep; 598 598 599 - ep = iscsi_create_endpoint(sizeof(*ib_conn)); 599 + ep = iscsi_create_endpoint(0); 600 600 if (!ep) 601 601 return ERR_PTR(-ENOMEM); 602 602 603 - ib_conn = ep->dd_data; 603 + ib_conn = kzalloc(sizeof(*ib_conn), GFP_KERNEL); 604 + if (!ib_conn) { 605 + err = -ENOMEM; 606 + goto failure; 607 + } 608 + 609 + ep->dd_data = ib_conn; 604 610 ib_conn->ep = ep; 605 611 iser_conn_init(ib_conn); 606 612 607 - err = iser_connect(ib_conn, NULL, (struct sockaddr_in *)dst_addr, 608 - non_blocking); 613 + err = iser_connect(ib_conn, NULL, dst_addr, non_blocking); 609 614 if (err) 610 - return ERR_PTR(err); 615 + goto failure; 611 616 612 617 return ep; 618 + failure: 619 + iscsi_destroy_endpoint(ep); 620 + return ERR_PTR(err); 613 621 } 614 622 615 623 static int ··· 627 619 int rc; 628 620 629 621 ib_conn = ep->dd_data; 630 - rc = wait_event_interruptible_timeout(ib_conn->wait, 631 - ib_conn->state == ISER_CONN_UP, 632 - msecs_to_jiffies(timeout_ms)); 633 - 622 + rc = wait_for_completion_interruptible_timeout(&ib_conn->up_completion, 623 + msecs_to_jiffies(timeout_ms)); 634 624 /* if conn establishment failed, return error code to iscsi */ 635 - if (!rc && 636 - (ib_conn->state == ISER_CONN_TERMINATING || 637 - ib_conn->state == ISER_CONN_DOWN)) 638 - rc = -1; 625 + if (rc == 0) { 626 + mutex_lock(&ib_conn->state_mutex); 627 + if (ib_conn->state == ISER_CONN_TERMINATING || 628 + ib_conn->state == ISER_CONN_DOWN) 629 + rc = -1; 630 + mutex_unlock(&ib_conn->state_mutex); 631 + } 639 632 640 633 iser_info("ib conn %p rc = %d\n", ib_conn, rc); 641 634 ··· 655 646 656 647 ib_conn = ep->dd_data; 657 648 iser_info("ep %p ib conn %p state %d\n", ep, ib_conn, ib_conn->state); 649 + mutex_lock(&ib_conn->state_mutex); 658 650 iser_conn_terminate(ib_conn); 659 651 660 652 /* 661 - * if iser_conn and iscsi_conn are bound, we must wait iscsi_conn_stop 662 - * call and ISER_CONN_DOWN state before freeing the iser resources. 663 - * otherwise we are safe to free resources immediately. 653 + * if iser_conn and iscsi_conn are bound, we must wait for 654 + * iscsi_conn_stop and flush errors completion before freeing 655 + * the iser resources. Otherwise we are safe to free resources 656 + * immediately. 664 657 */ 665 658 if (ib_conn->iscsi_conn) { 666 659 INIT_WORK(&ib_conn->release_work, iser_release_work); 667 660 queue_work(release_wq, &ib_conn->release_work); 661 + mutex_unlock(&ib_conn->state_mutex); 668 662 } else { 663 + ib_conn->state = ISER_CONN_DOWN; 664 + mutex_unlock(&ib_conn->state_mutex); 669 665 iser_conn_release(ib_conn); 670 666 } 667 + iscsi_destroy_endpoint(ep); 671 668 } 672 669 673 670 static umode_t iser_attr_is_visible(int param_type, int param)
+5 -3
drivers/infiniband/ulp/iser/iscsi_iser.h
··· 326 326 struct iser_device *device; /* device context */ 327 327 struct rdma_cm_id *cma_id; /* CMA ID */ 328 328 struct ib_qp *qp; /* QP */ 329 - wait_queue_head_t wait; /* waitq for conn/disconn */ 330 329 unsigned qp_max_recv_dtos; /* num of rx buffers */ 331 330 unsigned qp_max_recv_dtos_mask; /* above minus 1 */ 332 331 unsigned min_posted_rx; /* qp_max_recv_dtos >> 2 */ ··· 334 335 char name[ISER_OBJECT_NAME_SIZE]; 335 336 struct work_struct release_work; 336 337 struct completion stop_completion; 338 + struct mutex state_mutex; 339 + struct completion flush_completion; 340 + struct completion up_completion; 337 341 struct list_head conn_list; /* entry in ig conn list */ 338 342 339 343 char *login_buf; ··· 450 448 enum iser_data_dir cmd_dir); 451 449 452 450 int iser_connect(struct iser_conn *ib_conn, 453 - struct sockaddr_in *src_addr, 454 - struct sockaddr_in *dst_addr, 451 + struct sockaddr *src_addr, 452 + struct sockaddr *dst_addr, 455 453 int non_blocking); 456 454 457 455 int iser_reg_page_vec(struct iser_conn *ib_conn,
+84 -44
drivers/infiniband/ulp/iser/iser_verbs.c
··· 491 491 } 492 492 493 493 /** 494 - * releases the QP objects, returns 0 on success, 495 - * -1 on failure 494 + * releases the QP object 496 495 */ 497 - static int iser_free_ib_conn_res(struct iser_conn *ib_conn) 496 + static void iser_free_ib_conn_res(struct iser_conn *ib_conn) 498 497 { 499 498 int cq_index; 500 499 BUG_ON(ib_conn == NULL); ··· 512 513 } 513 514 514 515 ib_conn->qp = NULL; 515 - 516 - return 0; 517 516 } 518 517 519 518 /** ··· 565 568 mutex_unlock(&ig.device_list_mutex); 566 569 } 567 570 571 + /** 572 + * Called with state mutex held 573 + **/ 568 574 static int iser_conn_state_comp_exch(struct iser_conn *ib_conn, 569 575 enum iser_ib_conn_state comp, 570 576 enum iser_ib_conn_state exch) 571 577 { 572 578 int ret; 573 579 574 - spin_lock_bh(&ib_conn->lock); 575 580 if ((ret = (ib_conn->state == comp))) 576 581 ib_conn->state = exch; 577 - spin_unlock_bh(&ib_conn->lock); 578 582 return ret; 579 583 } 580 584 581 585 void iser_release_work(struct work_struct *work) 582 586 { 583 587 struct iser_conn *ib_conn; 588 + int rc; 584 589 585 590 ib_conn = container_of(work, struct iser_conn, release_work); 586 591 587 592 /* wait for .conn_stop callback */ 588 - wait_for_completion(&ib_conn->stop_completion); 593 + rc = wait_for_completion_timeout(&ib_conn->stop_completion, 30 * HZ); 594 + WARN_ON(rc == 0); 589 595 590 596 /* wait for the qp`s post send and post receive buffers to empty */ 591 - wait_event_interruptible(ib_conn->wait, 592 - ib_conn->state == ISER_CONN_DOWN); 597 + rc = wait_for_completion_timeout(&ib_conn->flush_completion, 30 * HZ); 598 + WARN_ON(rc == 0); 599 + 600 + ib_conn->state = ISER_CONN_DOWN; 601 + 602 + mutex_lock(&ib_conn->state_mutex); 603 + ib_conn->state = ISER_CONN_DOWN; 604 + mutex_unlock(&ib_conn->state_mutex); 593 605 594 606 iser_conn_release(ib_conn); 595 607 } ··· 610 604 { 611 605 struct iser_device *device = ib_conn->device; 612 606 613 - BUG_ON(ib_conn->state == ISER_CONN_UP); 614 - 615 607 mutex_lock(&ig.connlist_mutex); 616 608 list_del(&ib_conn->conn_list); 617 609 mutex_unlock(&ig.connlist_mutex); 610 + 611 + mutex_lock(&ib_conn->state_mutex); 612 + BUG_ON(ib_conn->state != ISER_CONN_DOWN); 613 + 618 614 iser_free_rx_descriptors(ib_conn); 619 615 iser_free_ib_conn_res(ib_conn); 620 616 ib_conn->device = NULL; 621 617 /* on EVENT_ADDR_ERROR there's no device yet for this conn */ 622 618 if (device != NULL) 623 619 iser_device_try_release(device); 620 + mutex_unlock(&ib_conn->state_mutex); 621 + 624 622 /* if cma handler context, the caller actually destroy the id */ 625 623 if (ib_conn->cma_id != NULL) { 626 624 rdma_destroy_id(ib_conn->cma_id); 627 625 ib_conn->cma_id = NULL; 628 626 } 629 - iscsi_destroy_endpoint(ib_conn->ep); 627 + kfree(ib_conn); 630 628 } 631 629 632 630 /** ··· 652 642 ib_conn,err); 653 643 } 654 644 645 + /** 646 + * Called with state mutex held 647 + **/ 655 648 static void iser_connect_error(struct rdma_cm_id *cma_id) 656 649 { 657 650 struct iser_conn *ib_conn; 658 651 659 652 ib_conn = (struct iser_conn *)cma_id->context; 660 - 661 653 ib_conn->state = ISER_CONN_DOWN; 662 - wake_up_interruptible(&ib_conn->wait); 663 654 } 664 655 656 + /** 657 + * Called with state mutex held 658 + **/ 665 659 static void iser_addr_handler(struct rdma_cm_id *cma_id) 666 660 { 667 661 struct iser_device *device; 668 662 struct iser_conn *ib_conn; 669 663 int ret; 664 + 665 + ib_conn = (struct iser_conn *)cma_id->context; 666 + if (ib_conn->state != ISER_CONN_PENDING) 667 + /* bailout */ 668 + return; 670 669 671 670 device = iser_device_find_by_ib_device(cma_id); 672 671 if (!device) { ··· 684 665 return; 685 666 } 686 667 687 - ib_conn = (struct iser_conn *)cma_id->context; 688 668 ib_conn->device = device; 689 669 690 670 /* connection T10-PI support */ ··· 707 689 } 708 690 } 709 691 692 + /** 693 + * Called with state mutex held 694 + **/ 710 695 static void iser_route_handler(struct rdma_cm_id *cma_id) 711 696 { 712 697 struct rdma_conn_param conn_param; 713 698 int ret; 714 699 struct iser_cm_hdr req_hdr; 700 + struct iser_conn *ib_conn = (struct iser_conn *)cma_id->context; 701 + struct iser_device *device = ib_conn->device; 702 + 703 + if (ib_conn->state != ISER_CONN_PENDING) 704 + /* bailout */ 705 + return; 715 706 716 707 ret = iser_create_ib_conn_res((struct iser_conn *)cma_id->context); 717 708 if (ret) 718 709 goto failure; 719 710 720 711 memset(&conn_param, 0, sizeof conn_param); 721 - conn_param.responder_resources = 4; 712 + conn_param.responder_resources = device->dev_attr.max_qp_rd_atom; 722 713 conn_param.initiator_depth = 1; 723 714 conn_param.retry_count = 7; 724 715 conn_param.rnr_retry_count = 6; ··· 755 728 struct ib_qp_attr attr; 756 729 struct ib_qp_init_attr init_attr; 757 730 731 + ib_conn = (struct iser_conn *)cma_id->context; 732 + if (ib_conn->state != ISER_CONN_PENDING) 733 + /* bailout */ 734 + return; 735 + 758 736 (void)ib_query_qp(cma_id->qp, &attr, ~0, &init_attr); 759 737 iser_info("remote qpn:%x my qpn:%x\n", attr.dest_qp_num, cma_id->qp->qp_num); 760 738 761 - ib_conn = (struct iser_conn *)cma_id->context; 762 - if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_PENDING, ISER_CONN_UP)) 763 - wake_up_interruptible(&ib_conn->wait); 739 + ib_conn->state = ISER_CONN_UP; 740 + complete(&ib_conn->up_completion); 764 741 } 765 742 766 743 static void iser_disconnected_handler(struct rdma_cm_id *cma_id) ··· 783 752 iser_err("iscsi_iser connection isn't bound\n"); 784 753 } 785 754 786 - /* Complete the termination process if no posts are pending */ 755 + /* Complete the termination process if no posts are pending. This code 756 + * block also exists in iser_handle_comp_error(), but it is needed here 757 + * for cases of no flushes at all, e.g. discovery over rdma. 758 + */ 787 759 if (ib_conn->post_recv_buf_count == 0 && 788 760 (atomic_read(&ib_conn->post_send_buf_count) == 0)) { 789 - ib_conn->state = ISER_CONN_DOWN; 790 - wake_up_interruptible(&ib_conn->wait); 761 + complete(&ib_conn->flush_completion); 791 762 } 792 763 } 793 764 794 765 static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) 795 766 { 767 + struct iser_conn *ib_conn; 768 + 769 + ib_conn = (struct iser_conn *)cma_id->context; 796 770 iser_info("event %d status %d conn %p id %p\n", 797 771 event->event, event->status, cma_id->context, cma_id); 798 772 773 + mutex_lock(&ib_conn->state_mutex); 799 774 switch (event->event) { 800 775 case RDMA_CM_EVENT_ADDR_RESOLVED: 801 776 iser_addr_handler(cma_id); ··· 822 785 case RDMA_CM_EVENT_DISCONNECTED: 823 786 case RDMA_CM_EVENT_DEVICE_REMOVAL: 824 787 case RDMA_CM_EVENT_ADDR_CHANGE: 788 + case RDMA_CM_EVENT_TIMEWAIT_EXIT: 825 789 iser_disconnected_handler(cma_id); 826 790 break; 827 791 default: 828 792 iser_err("Unexpected RDMA CM event (%d)\n", event->event); 829 793 break; 830 794 } 795 + mutex_unlock(&ib_conn->state_mutex); 831 796 return 0; 832 797 } 833 798 834 799 void iser_conn_init(struct iser_conn *ib_conn) 835 800 { 836 801 ib_conn->state = ISER_CONN_INIT; 837 - init_waitqueue_head(&ib_conn->wait); 838 802 ib_conn->post_recv_buf_count = 0; 839 803 atomic_set(&ib_conn->post_send_buf_count, 0); 840 804 init_completion(&ib_conn->stop_completion); 805 + init_completion(&ib_conn->flush_completion); 806 + init_completion(&ib_conn->up_completion); 841 807 INIT_LIST_HEAD(&ib_conn->conn_list); 842 808 spin_lock_init(&ib_conn->lock); 809 + mutex_init(&ib_conn->state_mutex); 843 810 } 844 811 845 812 /** ··· 851 810 * sleeps until the connection is established or rejected 852 811 */ 853 812 int iser_connect(struct iser_conn *ib_conn, 854 - struct sockaddr_in *src_addr, 855 - struct sockaddr_in *dst_addr, 813 + struct sockaddr *src_addr, 814 + struct sockaddr *dst_addr, 856 815 int non_blocking) 857 816 { 858 - struct sockaddr *src, *dst; 859 817 int err = 0; 860 818 861 - sprintf(ib_conn->name, "%pI4:%d", 862 - &dst_addr->sin_addr.s_addr, dst_addr->sin_port); 819 + mutex_lock(&ib_conn->state_mutex); 820 + 821 + sprintf(ib_conn->name, "%pISp", dst_addr); 822 + 823 + iser_info("connecting to: %s\n", ib_conn->name); 863 824 864 825 /* the device is known only --after-- address resolution */ 865 826 ib_conn->device = NULL; 866 - 867 - iser_info("connecting to: %pI4, port 0x%x\n", 868 - &dst_addr->sin_addr, dst_addr->sin_port); 869 827 870 828 ib_conn->state = ISER_CONN_PENDING; 871 829 ··· 877 837 goto id_failure; 878 838 } 879 839 880 - src = (struct sockaddr *)src_addr; 881 - dst = (struct sockaddr *)dst_addr; 882 - err = rdma_resolve_addr(ib_conn->cma_id, src, dst, 1000); 840 + err = rdma_resolve_addr(ib_conn->cma_id, src_addr, dst_addr, 1000); 883 841 if (err) { 884 842 iser_err("rdma_resolve_addr failed: %d\n", err); 885 843 goto addr_failure; 886 844 } 887 845 888 846 if (!non_blocking) { 889 - wait_event_interruptible(ib_conn->wait, 890 - (ib_conn->state != ISER_CONN_PENDING)); 847 + wait_for_completion_interruptible(&ib_conn->up_completion); 891 848 892 849 if (ib_conn->state != ISER_CONN_UP) { 893 850 err = -EIO; 894 851 goto connect_failure; 895 852 } 896 853 } 854 + mutex_unlock(&ib_conn->state_mutex); 897 855 898 856 mutex_lock(&ig.connlist_mutex); 899 857 list_add(&ib_conn->conn_list, &ig.connlist); ··· 903 865 addr_failure: 904 866 ib_conn->state = ISER_CONN_DOWN; 905 867 connect_failure: 868 + mutex_unlock(&ib_conn->state_mutex); 906 869 iser_conn_release(ib_conn); 907 870 return err; 908 871 } ··· 1088 1049 1089 1050 if (ib_conn->post_recv_buf_count == 0 && 1090 1051 atomic_read(&ib_conn->post_send_buf_count) == 0) { 1091 - /* getting here when the state is UP means that the conn is * 1092 - * being terminated asynchronously from the iSCSI layer's * 1093 - * perspective. */ 1094 - if (iser_conn_state_comp_exch(ib_conn, ISER_CONN_UP, 1095 - ISER_CONN_TERMINATING)) 1052 + /** 1053 + * getting here when the state is UP means that the conn is 1054 + * being terminated asynchronously from the iSCSI layer's 1055 + * perspective. It is safe to peek at the connection state 1056 + * since iscsi_conn_failure is allowed to be called twice. 1057 + **/ 1058 + if (ib_conn->state == ISER_CONN_UP) 1096 1059 iscsi_conn_failure(ib_conn->iscsi_conn, 1097 1060 ISCSI_ERR_CONN_FAILED); 1098 1061 1099 1062 /* no more non completed posts to the QP, complete the 1100 1063 * termination process w.o worrying on disconnect event */ 1101 - ib_conn->state = ISER_CONN_DOWN; 1102 - wake_up_interruptible(&ib_conn->wait); 1064 + complete(&ib_conn->flush_completion); 1103 1065 } 1104 1066 } 1105 1067
+35 -13
drivers/infiniband/ulp/srp/ib_srp.c
··· 130 130 static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event); 131 131 132 132 static struct scsi_transport_template *ib_srp_transport_template; 133 + static struct workqueue_struct *srp_remove_wq; 133 134 134 135 static struct ib_client srp_client = { 135 136 .name = "srp", ··· 732 731 spin_unlock_irq(&target->lock); 733 732 734 733 if (changed) 735 - queue_work(system_long_wq, &target->remove_work); 734 + queue_work(srp_remove_wq, &target->remove_work); 736 735 737 736 return changed; 738 737 } ··· 1644 1643 SCSI_SENSE_BUFFERSIZE)); 1645 1644 } 1646 1645 1647 - if (rsp->flags & (SRP_RSP_FLAG_DOOVER | SRP_RSP_FLAG_DOUNDER)) 1648 - scsi_set_resid(scmnd, be32_to_cpu(rsp->data_out_res_cnt)); 1649 - else if (rsp->flags & (SRP_RSP_FLAG_DIOVER | SRP_RSP_FLAG_DIUNDER)) 1646 + if (unlikely(rsp->flags & SRP_RSP_FLAG_DIUNDER)) 1650 1647 scsi_set_resid(scmnd, be32_to_cpu(rsp->data_in_res_cnt)); 1648 + else if (unlikely(rsp->flags & SRP_RSP_FLAG_DIOVER)) 1649 + scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_in_res_cnt)); 1650 + else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOUNDER)) 1651 + scsi_set_resid(scmnd, be32_to_cpu(rsp->data_out_res_cnt)); 1652 + else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOOVER)) 1653 + scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_out_res_cnt)); 1651 1654 1652 1655 srp_free_req(target, req, scmnd, 1653 1656 be32_to_cpu(rsp->req_lim_delta)); ··· 3266 3261 spin_unlock(&host->target_lock); 3267 3262 3268 3263 /* 3269 - * Wait for target port removal tasks. 3264 + * Wait for tl_err and target port removal tasks. 3270 3265 */ 3271 3266 flush_workqueue(system_long_wq); 3267 + flush_workqueue(srp_remove_wq); 3272 3268 3273 3269 kfree(host); 3274 3270 } ··· 3319 3313 indirect_sg_entries = cmd_sg_entries; 3320 3314 } 3321 3315 3316 + srp_remove_wq = create_workqueue("srp_remove"); 3317 + if (!srp_remove_wq) { 3318 + ret = -ENOMEM; 3319 + goto out; 3320 + } 3321 + 3322 + ret = -ENOMEM; 3322 3323 ib_srp_transport_template = 3323 3324 srp_attach_transport(&ib_srp_transport_functions); 3324 3325 if (!ib_srp_transport_template) 3325 - return -ENOMEM; 3326 + goto destroy_wq; 3326 3327 3327 3328 ret = class_register(&srp_class); 3328 3329 if (ret) { 3329 3330 pr_err("couldn't register class infiniband_srp\n"); 3330 - srp_release_transport(ib_srp_transport_template); 3331 - return ret; 3331 + goto release_tr; 3332 3332 } 3333 3333 3334 3334 ib_sa_register_client(&srp_sa_client); ··· 3342 3330 ret = ib_register_client(&srp_client); 3343 3331 if (ret) { 3344 3332 pr_err("couldn't register IB client\n"); 3345 - srp_release_transport(ib_srp_transport_template); 3346 - ib_sa_unregister_client(&srp_sa_client); 3347 - class_unregister(&srp_class); 3348 - return ret; 3333 + goto unreg_sa; 3349 3334 } 3350 3335 3351 - return 0; 3336 + out: 3337 + return ret; 3338 + 3339 + unreg_sa: 3340 + ib_sa_unregister_client(&srp_sa_client); 3341 + class_unregister(&srp_class); 3342 + 3343 + release_tr: 3344 + srp_release_transport(ib_srp_transport_template); 3345 + 3346 + destroy_wq: 3347 + destroy_workqueue(srp_remove_wq); 3348 + goto out; 3352 3349 } 3353 3350 3354 3351 static void __exit srp_cleanup_module(void) ··· 3366 3345 ib_sa_unregister_client(&srp_sa_client); 3367 3346 class_unregister(&srp_class); 3368 3347 srp_release_transport(ib_srp_transport_template); 3348 + destroy_workqueue(srp_remove_wq); 3369 3349 } 3370 3350 3371 3351 module_init(srp_init_module);
+2 -1
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 198 198 case IB_EVENT_PKEY_CHANGE: 199 199 case IB_EVENT_SM_CHANGE: 200 200 case IB_EVENT_CLIENT_REREGISTER: 201 + case IB_EVENT_GID_CHANGE: 201 202 /* Refresh port data asynchronously. */ 202 203 if (event->element.port_num <= sdev->device->phys_port_cnt) { 203 204 sport = &sdev->port[event->element.port_num - 1]; ··· 564 563 &reg_req, 0, 565 564 srpt_mad_send_handler, 566 565 srpt_mad_recv_handler, 567 - sport); 566 + sport, 0); 568 567 if (IS_ERR(sport->mad_agent)) { 569 568 ret = PTR_ERR(sport->mad_agent); 570 569 sport->mad_agent = NULL;
+1
drivers/net/ethernet/emulex/benet/be.h
··· 890 890 */ 891 891 void be_roce_dev_open(struct be_adapter *); 892 892 void be_roce_dev_close(struct be_adapter *); 893 + void be_roce_dev_shutdown(struct be_adapter *); 893 894 894 895 #endif /* BE_H */
+1
drivers/net/ethernet/emulex/benet/be_main.c
··· 4958 4958 if (!adapter) 4959 4959 return; 4960 4960 4961 + be_roce_dev_shutdown(adapter); 4961 4962 cancel_delayed_work_sync(&adapter->work); 4962 4963 cancel_delayed_work_sync(&adapter->func_recovery_work); 4963 4964
+16 -2
drivers/net/ethernet/emulex/benet/be_roce.c
··· 120 120 { 121 121 if (ocrdma_drv && adapter->ocrdma_dev && 122 122 ocrdma_drv->state_change_handler) 123 - ocrdma_drv->state_change_handler(adapter->ocrdma_dev, 0); 123 + ocrdma_drv->state_change_handler(adapter->ocrdma_dev, 124 + BE_DEV_UP); 124 125 } 125 126 126 127 void be_roce_dev_open(struct be_adapter *adapter) ··· 137 136 { 138 137 if (ocrdma_drv && adapter->ocrdma_dev && 139 138 ocrdma_drv->state_change_handler) 140 - ocrdma_drv->state_change_handler(adapter->ocrdma_dev, 1); 139 + ocrdma_drv->state_change_handler(adapter->ocrdma_dev, 140 + BE_DEV_DOWN); 141 141 } 142 142 143 143 void be_roce_dev_close(struct be_adapter *adapter) ··· 146 144 if (be_roce_supported(adapter)) { 147 145 mutex_lock(&be_adapter_list_lock); 148 146 _be_roce_dev_close(adapter); 147 + mutex_unlock(&be_adapter_list_lock); 148 + } 149 + } 150 + 151 + void be_roce_dev_shutdown(struct be_adapter *adapter) 152 + { 153 + if (be_roce_supported(adapter)) { 154 + mutex_lock(&be_adapter_list_lock); 155 + if (ocrdma_drv && adapter->ocrdma_dev && 156 + ocrdma_drv->state_change_handler) 157 + ocrdma_drv->state_change_handler(adapter->ocrdma_dev, 158 + BE_DEV_SHUTDOWN); 149 159 mutex_unlock(&be_adapter_list_lock); 150 160 } 151 161 }
+2 -1
drivers/net/ethernet/emulex/benet/be_roce.h
··· 62 62 63 63 enum { 64 64 BE_DEV_UP = 0, 65 - BE_DEV_DOWN = 1 65 + BE_DEV_DOWN = 1, 66 + BE_DEV_SHUTDOWN = 2 66 67 }; 67 68 68 69 /* APIs for RoCE driver to register callback handlers,
+9
drivers/net/ethernet/mellanox/mlx4/cmd.c
··· 1311 1311 .wrapper = mlx4_MAD_IFC_wrapper 1312 1312 }, 1313 1313 { 1314 + .opcode = MLX4_CMD_MAD_DEMUX, 1315 + .has_inbox = false, 1316 + .has_outbox = false, 1317 + .out_is_imm = false, 1318 + .encode_slave_id = false, 1319 + .verify = NULL, 1320 + .wrapper = mlx4_CMD_EPERM_wrapper 1321 + }, 1322 + { 1314 1323 .opcode = MLX4_CMD_QUERY_IF_STAT, 1315 1324 .has_inbox = false, 1316 1325 .has_outbox = true,
+90 -1
drivers/net/ethernet/mellanox/mlx4/fw.c
··· 136 136 [7] = "FSM (MAC anti-spoofing) support", 137 137 [8] = "Dynamic QP updates support", 138 138 [9] = "Device managed flow steering IPoIB support", 139 - [10] = "TCP/IP offloads/flow-steering for VXLAN support" 139 + [10] = "TCP/IP offloads/flow-steering for VXLAN support", 140 + [11] = "MAD DEMUX (Secure-Host) support" 140 141 }; 141 142 int i; 142 143 ··· 572 571 #define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0 573 572 #define QUERY_DEV_CAP_FW_REASSIGN_MAC 0x9d 574 573 #define QUERY_DEV_CAP_VXLAN 0x9e 574 + #define QUERY_DEV_CAP_MAD_DEMUX_OFFSET 0xb0 575 575 576 576 dev_cap->flags2 = 0; 577 577 mailbox = mlx4_alloc_cmd_mailbox(dev); ··· 749 747 if (dev_cap->flags & MLX4_DEV_CAP_FLAG_COUNTERS) 750 748 MLX4_GET(dev_cap->max_counters, outbox, 751 749 QUERY_DEV_CAP_MAX_COUNTERS_OFFSET); 750 + 751 + MLX4_GET(field32, outbox, 752 + QUERY_DEV_CAP_MAD_DEMUX_OFFSET); 753 + if (field32 & (1 << 0)) 754 + dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_MAD_DEMUX; 752 755 753 756 MLX4_GET(field32, outbox, QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET); 754 757 if (field32 & (1 << 16)) ··· 2022 2015 2023 2016 out: 2024 2017 mlx4_free_cmd_mailbox(dev, mailbox); 2018 + } 2019 + 2020 + static int mlx4_check_smp_firewall_active(struct mlx4_dev *dev, 2021 + struct mlx4_cmd_mailbox *mailbox) 2022 + { 2023 + #define MLX4_CMD_MAD_DEMUX_SET_ATTR_OFFSET 0x10 2024 + #define MLX4_CMD_MAD_DEMUX_GETRESP_ATTR_OFFSET 0x20 2025 + #define MLX4_CMD_MAD_DEMUX_TRAP_ATTR_OFFSET 0x40 2026 + #define MLX4_CMD_MAD_DEMUX_TRAP_REPRESS_ATTR_OFFSET 0x70 2027 + 2028 + u32 set_attr_mask, getresp_attr_mask; 2029 + u32 trap_attr_mask, traprepress_attr_mask; 2030 + 2031 + MLX4_GET(set_attr_mask, mailbox->buf, 2032 + MLX4_CMD_MAD_DEMUX_SET_ATTR_OFFSET); 2033 + mlx4_dbg(dev, "SMP firewall set_attribute_mask = 0x%x\n", 2034 + set_attr_mask); 2035 + 2036 + MLX4_GET(getresp_attr_mask, mailbox->buf, 2037 + MLX4_CMD_MAD_DEMUX_GETRESP_ATTR_OFFSET); 2038 + mlx4_dbg(dev, "SMP firewall getresp_attribute_mask = 0x%x\n", 2039 + getresp_attr_mask); 2040 + 2041 + MLX4_GET(trap_attr_mask, mailbox->buf, 2042 + MLX4_CMD_MAD_DEMUX_TRAP_ATTR_OFFSET); 2043 + mlx4_dbg(dev, "SMP firewall trap_attribute_mask = 0x%x\n", 2044 + trap_attr_mask); 2045 + 2046 + MLX4_GET(traprepress_attr_mask, mailbox->buf, 2047 + MLX4_CMD_MAD_DEMUX_TRAP_REPRESS_ATTR_OFFSET); 2048 + mlx4_dbg(dev, "SMP firewall traprepress_attribute_mask = 0x%x\n", 2049 + traprepress_attr_mask); 2050 + 2051 + if (set_attr_mask && getresp_attr_mask && trap_attr_mask && 2052 + traprepress_attr_mask) 2053 + return 1; 2054 + 2055 + return 0; 2056 + } 2057 + 2058 + int mlx4_config_mad_demux(struct mlx4_dev *dev) 2059 + { 2060 + struct mlx4_cmd_mailbox *mailbox; 2061 + int secure_host_active; 2062 + int err; 2063 + 2064 + /* Check if mad_demux is supported */ 2065 + if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_MAD_DEMUX)) 2066 + return 0; 2067 + 2068 + mailbox = mlx4_alloc_cmd_mailbox(dev); 2069 + if (IS_ERR(mailbox)) { 2070 + mlx4_warn(dev, "Failed to allocate mailbox for cmd MAD_DEMUX"); 2071 + return -ENOMEM; 2072 + } 2073 + 2074 + /* Query mad_demux to find out which MADs are handled by internal sma */ 2075 + err = mlx4_cmd_box(dev, 0, mailbox->dma, 0x01 /* subn mgmt class */, 2076 + MLX4_CMD_MAD_DEMUX_QUERY_RESTR, MLX4_CMD_MAD_DEMUX, 2077 + MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 2078 + if (err) { 2079 + mlx4_warn(dev, "MLX4_CMD_MAD_DEMUX: query restrictions failed (%d)\n", 2080 + err); 2081 + goto out; 2082 + } 2083 + 2084 + secure_host_active = mlx4_check_smp_firewall_active(dev, mailbox); 2085 + 2086 + /* Config mad_demux to handle all MADs returned by the query above */ 2087 + err = mlx4_cmd(dev, mailbox->dma, 0x01 /* subn mgmt class */, 2088 + MLX4_CMD_MAD_DEMUX_CONFIG, MLX4_CMD_MAD_DEMUX, 2089 + MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 2090 + if (err) { 2091 + mlx4_warn(dev, "MLX4_CMD_MAD_DEMUX: configure failed (%d)\n", err); 2092 + goto out; 2093 + } 2094 + 2095 + if (secure_host_active) 2096 + mlx4_warn(dev, "HCA operating in secure-host mode. SMP firewall activated.\n"); 2097 + out: 2098 + mlx4_free_cmd_mailbox(dev, mailbox); 2099 + return err; 2025 2100 }
+5
drivers/net/ethernet/mellanox/mlx4/main.c
··· 1831 1831 mlx4_err(dev, "Failed to initialize multicast group table, aborting\n"); 1832 1832 goto err_mr_table_free; 1833 1833 } 1834 + err = mlx4_config_mad_demux(dev); 1835 + if (err) { 1836 + mlx4_err(dev, "Failed in config_mad_demux, aborting\n"); 1837 + goto err_mcg_table_free; 1838 + } 1834 1839 } 1835 1840 1836 1841 err = mlx4_init_eq_table(dev);
+1
drivers/net/ethernet/mellanox/mlx4/mlx4.h
··· 1313 1313 int mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave, int port); 1314 1314 /* Returns the VF index of slave */ 1315 1315 int mlx4_get_vf_indx(struct mlx4_dev *dev, int slave); 1316 + int mlx4_config_mad_demux(struct mlx4_dev *dev); 1316 1317 1317 1318 #endif /* MLX4_H */
+2 -1
drivers/scsi/scsi_transport_srp.c
··· 473 473 if (delay > 0) 474 474 queue_delayed_work(system_long_wq, &rport->reconnect_work, 475 475 1UL * delay * HZ); 476 - if (srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) { 476 + if ((fast_io_fail_tmo >= 0 || dev_loss_tmo >= 0) && 477 + srp_rport_set_state(rport, SRP_RPORT_BLOCKED) == 0) { 477 478 pr_debug("%s new state: %d\n", dev_name(&shost->shost_gendev), 478 479 rport->state); 479 480 scsi_target_block(&shost->shost_gendev);
+7
include/linux/mlx4/cmd.h
··· 116 116 /* special QP and management commands */ 117 117 MLX4_CMD_CONF_SPECIAL_QP = 0x23, 118 118 MLX4_CMD_MAD_IFC = 0x24, 119 + MLX4_CMD_MAD_DEMUX = 0x203, 119 120 120 121 /* multicast commands */ 121 122 MLX4_CMD_READ_MCG = 0x25, ··· 184 183 MLX4_SET_PORT_PRIO2TC = 0x8, 185 184 MLX4_SET_PORT_SCHEDULER = 0x9, 186 185 MLX4_SET_PORT_VXLAN = 0xB 186 + }; 187 + 188 + enum { 189 + MLX4_CMD_MAD_DEMUX_CONFIG = 0, 190 + MLX4_CMD_MAD_DEMUX_QUERY_STATE = 1, 191 + MLX4_CMD_MAD_DEMUX_QUERY_RESTR = 2, /* Query mad demux restrictions */ 187 192 }; 188 193 189 194 enum {
+1
include/linux/mlx4/device.h
··· 172 172 MLX4_DEV_CAP_FLAG2_UPDATE_QP = 1LL << 8, 173 173 MLX4_DEV_CAP_FLAG2_DMFS_IPOIB = 1LL << 9, 174 174 MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS = 1LL << 10, 175 + MLX4_DEV_CAP_FLAG2_MAD_DEMUX = 1LL << 11, 175 176 }; 176 177 177 178 enum {
+17 -1
include/rdma/ib_mad.h
··· 40 40 #include <linux/list.h> 41 41 42 42 #include <rdma/ib_verbs.h> 43 + #include <uapi/rdma/ib_user_mad.h> 43 44 44 45 /* Management base version */ 45 46 #define IB_MGMT_BASE_VERSION 1 ··· 356 355 * @hi_tid: Access layer assigned transaction ID for this client. 357 356 * Unsolicited MADs sent by this client will have the upper 32-bits 358 357 * of their TID set to this value. 358 + * @flags: registration flags 359 359 * @port_num: Port number on which QP is registered 360 360 * @rmpp_version: If set, indicates the RMPP version used by this agent. 361 361 */ 362 + enum { 363 + IB_MAD_USER_RMPP = IB_USER_MAD_USER_RMPP, 364 + }; 362 365 struct ib_mad_agent { 363 366 struct ib_device *device; 364 367 struct ib_qp *qp; ··· 372 367 ib_mad_snoop_handler snoop_handler; 373 368 void *context; 374 369 u32 hi_tid; 370 + u32 flags; 375 371 u8 port_num; 376 372 u8 rmpp_version; 377 373 }; ··· 432 426 * in the range from 0x30 to 0x4f. Otherwise not used. 433 427 * @method_mask: The caller will receive unsolicited MADs for any method 434 428 * where @method_mask = 1. 429 + * 435 430 */ 436 431 struct ib_mad_reg_req { 437 432 u8 mgmt_class; ··· 458 451 * @recv_handler: The completion callback routine invoked for a received 459 452 * MAD. 460 453 * @context: User specified context associated with the registration. 454 + * @registration_flags: Registration flags to set for this agent 461 455 */ 462 456 struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, 463 457 u8 port_num, ··· 467 459 u8 rmpp_version, 468 460 ib_mad_send_handler send_handler, 469 461 ib_mad_recv_handler recv_handler, 470 - void *context); 462 + void *context, 463 + u32 registration_flags); 471 464 472 465 enum ib_mad_snoop_flags { 473 466 /*IB_MAD_SNOOP_POSTED_SENDS = 1,*/ ··· 669 660 * @send_buf: Previously allocated send data buffer. 670 661 */ 671 662 void ib_free_send_mad(struct ib_mad_send_buf *send_buf); 663 + 664 + /** 665 + * ib_mad_kernel_rmpp_agent - Returns if the agent is performing RMPP. 666 + * @agent: the agent in question 667 + * @return: true if agent is performing rmpp, false otherwise. 668 + */ 669 + int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent); 672 670 673 671 #endif /* IB_MAD_H */
+42
include/uapi/rdma/ib_user_mad.h
··· 191 191 __u8 rmpp_version; 192 192 }; 193 193 194 + /** 195 + * ib_user_mad_reg_req2 - MAD registration request 196 + * 197 + * @id - Set by the _kernel_; used by userspace to identify the 198 + * registered agent in future requests. 199 + * @qpn - Queue pair number; must be 0 or 1. 200 + * @mgmt_class - Indicates which management class of MADs should be 201 + * receive by the caller. This field is only required if 202 + * the user wishes to receive unsolicited MADs, otherwise 203 + * it should be 0. 204 + * @mgmt_class_version - Indicates which version of MADs for the given 205 + * management class to receive. 206 + * @res - Ignored. 207 + * @flags - additional registration flags; Must be in the set of 208 + * flags defined in IB_USER_MAD_REG_FLAGS_CAP 209 + * @method_mask - The caller wishes to receive unsolicited MADs for the 210 + * methods whose bit(s) is(are) set. 211 + * @oui - Indicates IEEE OUI to use when mgmt_class is a vendor 212 + * class in the range from 0x30 to 0x4f. Otherwise not 213 + * used. 214 + * @rmpp_version - If set, indicates the RMPP version to use. 215 + */ 216 + enum { 217 + IB_USER_MAD_USER_RMPP = (1 << 0), 218 + }; 219 + #define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP) 220 + struct ib_user_mad_reg_req2 { 221 + __u32 id; 222 + __u32 qpn; 223 + __u8 mgmt_class; 224 + __u8 mgmt_class_version; 225 + __u16 res; 226 + __u32 flags; 227 + __u64 method_mask[2]; 228 + __u32 oui; 229 + __u8 rmpp_version; 230 + __u8 reserved[3]; 231 + }; 232 + 194 233 #define IB_IOCTL_MAGIC 0x1b 195 234 196 235 #define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \ ··· 238 199 #define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, __u32) 239 200 240 201 #define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3) 202 + 203 + #define IB_USER_MAD_REGISTER_AGENT2 _IOWR(IB_IOCTL_MAGIC, 4, \ 204 + struct ib_user_mad_reg_req2) 241 205 242 206 #endif /* IB_USER_MAD_H */
+1
include/uapi/rdma/rdma_user_cm.h
··· 34 34 #define RDMA_USER_CM_H 35 35 36 36 #include <linux/types.h> 37 + #include <linux/socket.h> 37 38 #include <linux/in6.h> 38 39 #include <rdma/ib_user_verbs.h> 39 40 #include <rdma/ib_user_sa.h>