Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband: (76 commits)
IB: Update MAINTAINERS with Hal's new email address
IB/mlx4: Implement query SRQ
IB/mlx4: Implement query QP
IB/cm: Send no match if a SIDR REQ does not match a listen
IB/cm: Fix handling of duplicate SIDR REQs
IB/cm: cm_msgs.h should include ib_cm.h
IB/cm: Include HCA ACK delay in local ACK timeout
IB/cm: Use spin_lock_irq() instead of spin_lock_irqsave() when possible
IB/sa: Make sure SA queries use default P_Key
IPoIB: Recycle loopback skbs instead of freeing and reallocating
IB/mthca: Replace memset(<addr>, 0, PAGE_SIZE) with clear_page(<addr>)
IPoIB/cm: Fix warning if IPV6 is not enabled
IB/core: Take sizeof the correct pointer when calling kmalloc()
IB/ehca: Improve latency by unlocking after triggering the hardware
IB/ehca: Notify consumers of LID/PKEY/SM changes after nondisruptive events
IB/ehca: Return QP pointer in poll_cq()
IB/ehca: Change idr spinlocks into rwlocks
IB/ehca: Refactor sync between completions and destroy_cq using atomic_t
IB/ehca: Lock renaming, static initializers
IB/ehca: Report RDMA atomic attributes in query_qp()
...

+2822 -1071
+8 -7
MAINTAINERS
··· 370 370 M: tom@opengridcomputing.com 371 371 P: Steve Wise 372 372 M: swise@opengridcomputing.com 373 - L: openib-general@openib.org 373 + L: general@lists.openfabrics.org 374 374 S: Maintained 375 375 376 376 AOA (Apple Onboard Audio) ALSA DRIVER ··· 1395 1395 M: hnguyen@de.ibm.com 1396 1396 P: Christoph Raisch 1397 1397 M: raisch@de.ibm.com 1398 - L: openib-general@openib.org 1398 + L: general@lists.openfabrics.org 1399 1399 S: Supported 1400 1400 1401 1401 EMU10K1 SOUND DRIVER ··· 1849 1849 P: Sean Hefty 1850 1850 M: mshefty@ichips.intel.com 1851 1851 P: Hal Rosenstock 1852 - M: halr@voltaire.com 1853 - L: openib-general@openib.org 1852 + M: hal.rosenstock@gmail.com 1853 + L: general@lists.openfabrics.org 1854 1854 W: http://www.openib.org/ 1855 1855 T: git kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git 1856 1856 S: Supported ··· 1988 1988 S: Maintained 1989 1989 1990 1990 IPATH DRIVER: 1991 - P: Bryan O'Sullivan 1992 - M: support@pathscale.com 1993 - L: openib-general@openib.org 1991 + P: Arthur Jones 1992 + M: infinipath@qlogic.com 1993 + L: general@lists.openfabrics.org 1994 + T: git git://git.qlogic.com/ipath-linux-2.6 1994 1995 S: Supported 1995 1996 1996 1997 IPMI SUBSYSTEM
+7 -8
drivers/infiniband/Kconfig
··· 1 - menu "InfiniBand support" 2 - depends on HAS_IOMEM 3 - 4 - config INFINIBAND 5 - depends on PCI || BROKEN 1 + menuconfig INFINIBAND 6 2 tristate "InfiniBand support" 3 + depends on PCI || BROKEN 4 + depends on HAS_IOMEM 7 5 ---help--- 8 6 Core support for InfiniBand (IB). Make sure to also select 9 7 any protocols you wish to use as well as drivers for your 10 8 InfiniBand hardware. 9 + 10 + if INFINIBAND 11 11 12 12 config INFINIBAND_USER_MAD 13 13 tristate "InfiniBand userspace MAD support" ··· 20 20 21 21 config INFINIBAND_USER_ACCESS 22 22 tristate "InfiniBand userspace access (verbs and CM)" 23 - depends on INFINIBAND 24 23 ---help--- 25 24 Userspace InfiniBand access support. This enables the 26 25 kernel side of userspace verbs and the userspace ··· 36 37 37 38 config INFINIBAND_ADDR_TRANS 38 39 bool 39 - depends on INFINIBAND && INET 40 + depends on INET 40 41 default y 41 42 42 43 source "drivers/infiniband/hw/mthca/Kconfig" ··· 53 54 54 55 source "drivers/infiniband/ulp/iser/Kconfig" 55 56 56 - endmenu 57 + endif # INFINIBAND
+16 -3
drivers/infiniband/core/agent.c
··· 3 3 * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved. 4 4 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. 5 5 * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved. 6 - * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved. 6 + * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved. 7 7 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 8 8 * 9 9 * This software is available to you under a choice of one of two ··· 34 34 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 35 * SOFTWARE. 36 36 * 37 - * $Id: agent.c 1389 2004-12-27 22:56:47Z roland $ 38 37 */ 39 38 40 39 #include <linux/slab.h> ··· 41 42 42 43 #include "agent.h" 43 44 #include "smi.h" 45 + #include "mad_priv.h" 44 46 45 47 #define SPFX "ib_agent: " 46 48 ··· 87 87 struct ib_mad_send_buf *send_buf; 88 88 struct ib_ah *ah; 89 89 int ret; 90 + struct ib_mad_send_wr_private *mad_send_wr; 90 91 91 - port_priv = ib_get_agent_port(device, port_num); 92 + if (device->node_type == RDMA_NODE_IB_SWITCH) 93 + port_priv = ib_get_agent_port(device, 0); 94 + else 95 + port_priv = ib_get_agent_port(device, port_num); 96 + 92 97 if (!port_priv) { 93 98 printk(KERN_ERR SPFX "Unable to find port agent\n"); 94 99 return -ENODEV; ··· 118 113 119 114 memcpy(send_buf->mad, mad, sizeof *mad); 120 115 send_buf->ah = ah; 116 + 117 + if (device->node_type == RDMA_NODE_IB_SWITCH) { 118 + mad_send_wr = container_of(send_buf, 119 + struct ib_mad_send_wr_private, 120 + send_buf); 121 + mad_send_wr->send_wr.wr.ud.port_num = port_num; 122 + } 123 + 121 124 if ((ret = ib_post_send_mad(send_buf, NULL))) { 122 125 printk(KERN_ERR SPFX "ib_post_send_mad error:%d\n", ret); 123 126 goto err2;
+134 -113
drivers/infiniband/core/cm.c
··· 87 87 struct cm_device { 88 88 struct list_head list; 89 89 struct ib_device *device; 90 + u8 ack_delay; 90 91 struct cm_port port[0]; 91 92 }; 92 93 ··· 96 95 union ib_gid dgid; 97 96 struct ib_ah_attr ah_attr; 98 97 u16 pkey_index; 99 - u8 packet_life_time; 98 + u8 timeout; 100 99 }; 101 100 102 101 struct cm_work { ··· 155 154 u8 retry_count; 156 155 u8 rnr_retry_count; 157 156 u8 service_timeout; 157 + u8 target_ack_delay; 158 158 159 159 struct list_head work_list; 160 160 atomic_t work_count; ··· 295 293 av->port = port; 296 294 ib_init_ah_from_path(cm_dev->device, port->port_num, path, 297 295 &av->ah_attr); 298 - av->packet_life_time = path->packet_life_time; 296 + av->timeout = path->packet_life_time + 1; 299 297 return 0; 300 298 } 301 299 ··· 320 318 321 319 static void cm_free_id(__be32 local_id) 322 320 { 323 - unsigned long flags; 324 - 325 - spin_lock_irqsave(&cm.lock, flags); 321 + spin_lock_irq(&cm.lock); 326 322 idr_remove(&cm.local_id_table, 327 323 (__force int) (local_id ^ cm.random_id_operand)); 328 - spin_unlock_irqrestore(&cm.lock, flags); 324 + spin_unlock_irq(&cm.lock); 329 325 } 330 326 331 327 static struct cm_id_private * cm_get_id(__be32 local_id, __be32 remote_id) ··· 345 345 static struct cm_id_private * cm_acquire_id(__be32 local_id, __be32 remote_id) 346 346 { 347 347 struct cm_id_private *cm_id_priv; 348 - unsigned long flags; 349 348 350 - spin_lock_irqsave(&cm.lock, flags); 349 + spin_lock_irq(&cm.lock); 351 350 cm_id_priv = cm_get_id(local_id, remote_id); 352 - spin_unlock_irqrestore(&cm.lock, flags); 351 + spin_unlock_irq(&cm.lock); 353 352 354 353 return cm_id_priv; 355 354 } ··· 645 646 return 1 << max(iba_time - 8, 0); 646 647 } 647 648 649 + /* 650 + * calculate: 4.096x2^ack_timeout = 4.096x2^ack_delay + 2x4.096x2^life_time 651 + * Because of how ack_timeout is stored, adding one doubles the timeout. 652 + * To avoid large timeouts, select the max(ack_delay, life_time + 1), and 653 + * increment it (round up) only if the other is within 50%. 654 + */ 655 + static u8 cm_ack_timeout(u8 ca_ack_delay, u8 packet_life_time) 656 + { 657 + int ack_timeout = packet_life_time + 1; 658 + 659 + if (ack_timeout >= ca_ack_delay) 660 + ack_timeout += (ca_ack_delay >= (ack_timeout - 1)); 661 + else 662 + ack_timeout = ca_ack_delay + 663 + (ack_timeout >= (ca_ack_delay - 1)); 664 + 665 + return min(31, ack_timeout); 666 + } 667 + 648 668 static void cm_cleanup_timewait(struct cm_timewait_info *timewait_info) 649 669 { 650 670 if (timewait_info->inserted_remote_id) { ··· 707 689 * timewait before notifying the user that we've exited timewait. 708 690 */ 709 691 cm_id_priv->id.state = IB_CM_TIMEWAIT; 710 - wait_time = cm_convert_to_ms(cm_id_priv->av.packet_life_time + 1); 692 + wait_time = cm_convert_to_ms(cm_id_priv->av.timeout); 711 693 queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work, 712 694 msecs_to_jiffies(wait_time)); 713 695 cm_id_priv->timewait_info = NULL; ··· 731 713 { 732 714 struct cm_id_private *cm_id_priv; 733 715 struct cm_work *work; 734 - unsigned long flags; 735 716 736 717 cm_id_priv = container_of(cm_id, struct cm_id_private, id); 737 718 retest: 738 - spin_lock_irqsave(&cm_id_priv->lock, flags); 719 + spin_lock_irq(&cm_id_priv->lock); 739 720 switch (cm_id->state) { 740 721 case IB_CM_LISTEN: 741 722 cm_id->state = IB_CM_IDLE; 742 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 743 - spin_lock_irqsave(&cm.lock, flags); 723 + spin_unlock_irq(&cm_id_priv->lock); 724 + spin_lock_irq(&cm.lock); 744 725 rb_erase(&cm_id_priv->service_node, &cm.listen_service_table); 745 - spin_unlock_irqrestore(&cm.lock, flags); 726 + spin_unlock_irq(&cm.lock); 746 727 break; 747 728 case IB_CM_SIDR_REQ_SENT: 748 729 cm_id->state = IB_CM_IDLE; 749 730 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); 750 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 731 + spin_unlock_irq(&cm_id_priv->lock); 751 732 break; 752 733 case IB_CM_SIDR_REQ_RCVD: 753 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 734 + spin_unlock_irq(&cm_id_priv->lock); 754 735 cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT); 755 736 break; 756 737 case IB_CM_REQ_SENT: 757 738 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); 758 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 739 + spin_unlock_irq(&cm_id_priv->lock); 759 740 ib_send_cm_rej(cm_id, IB_CM_REJ_TIMEOUT, 760 741 &cm_id_priv->id.device->node_guid, 761 742 sizeof cm_id_priv->id.device->node_guid, ··· 764 747 if (err == -ENOMEM) { 765 748 /* Do not reject to allow future retries. */ 766 749 cm_reset_to_idle(cm_id_priv); 767 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 750 + spin_unlock_irq(&cm_id_priv->lock); 768 751 } else { 769 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 752 + spin_unlock_irq(&cm_id_priv->lock); 770 753 ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED, 771 754 NULL, 0, NULL, 0); 772 755 } ··· 779 762 case IB_CM_MRA_REQ_SENT: 780 763 case IB_CM_REP_RCVD: 781 764 case IB_CM_MRA_REP_SENT: 782 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 765 + spin_unlock_irq(&cm_id_priv->lock); 783 766 ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED, 784 767 NULL, 0, NULL, 0); 785 768 break; 786 769 case IB_CM_ESTABLISHED: 787 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 770 + spin_unlock_irq(&cm_id_priv->lock); 788 771 ib_send_cm_dreq(cm_id, NULL, 0); 789 772 goto retest; 790 773 case IB_CM_DREQ_SENT: 791 774 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); 792 775 cm_enter_timewait(cm_id_priv); 793 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 776 + spin_unlock_irq(&cm_id_priv->lock); 794 777 break; 795 778 case IB_CM_DREQ_RCVD: 796 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 779 + spin_unlock_irq(&cm_id_priv->lock); 797 780 ib_send_cm_drep(cm_id, NULL, 0); 798 781 break; 799 782 default: 800 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 783 + spin_unlock_irq(&cm_id_priv->lock); 801 784 break; 802 785 } 803 786 ··· 929 912 cm_req_set_primary_sl(req_msg, param->primary_path->sl); 930 913 cm_req_set_primary_subnet_local(req_msg, 1); /* local only... */ 931 914 cm_req_set_primary_local_ack_timeout(req_msg, 932 - min(31, param->primary_path->packet_life_time + 1)); 915 + cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay, 916 + param->primary_path->packet_life_time)); 933 917 934 918 if (param->alternate_path) { 935 919 req_msg->alt_local_lid = param->alternate_path->slid; ··· 945 927 cm_req_set_alt_sl(req_msg, param->alternate_path->sl); 946 928 cm_req_set_alt_subnet_local(req_msg, 1); /* local only... */ 947 929 cm_req_set_alt_local_ack_timeout(req_msg, 948 - min(31, param->alternate_path->packet_life_time + 1)); 930 + cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay, 931 + param->alternate_path->packet_life_time)); 949 932 } 950 933 951 934 if (param->private_data && param->private_data_len) ··· 1188 1169 static void cm_process_work(struct cm_id_private *cm_id_priv, 1189 1170 struct cm_work *work) 1190 1171 { 1191 - unsigned long flags; 1192 1172 int ret; 1193 1173 1194 1174 /* We will typically only have the current event to report. */ ··· 1195 1177 cm_free_work(work); 1196 1178 1197 1179 while (!ret && !atomic_add_negative(-1, &cm_id_priv->work_count)) { 1198 - spin_lock_irqsave(&cm_id_priv->lock, flags); 1180 + spin_lock_irq(&cm_id_priv->lock); 1199 1181 work = cm_dequeue_work(cm_id_priv); 1200 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1182 + spin_unlock_irq(&cm_id_priv->lock); 1201 1183 BUG_ON(!work); 1202 1184 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, 1203 1185 &work->cm_event); ··· 1268 1250 struct cm_id_private *cm_id_priv) 1269 1251 { 1270 1252 struct ib_mad_send_buf *msg = NULL; 1271 - unsigned long flags; 1272 1253 int ret; 1273 1254 1274 1255 /* Quick state check to discard duplicate REQs. */ ··· 1278 1261 if (ret) 1279 1262 return; 1280 1263 1281 - spin_lock_irqsave(&cm_id_priv->lock, flags); 1264 + spin_lock_irq(&cm_id_priv->lock); 1282 1265 switch (cm_id_priv->id.state) { 1283 1266 case IB_CM_MRA_REQ_SENT: 1284 1267 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, ··· 1293 1276 default: 1294 1277 goto unlock; 1295 1278 } 1296 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1279 + spin_unlock_irq(&cm_id_priv->lock); 1297 1280 1298 1281 ret = ib_post_send_mad(msg, NULL); 1299 1282 if (ret) 1300 1283 goto free; 1301 1284 return; 1302 1285 1303 - unlock: spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1286 + unlock: spin_unlock_irq(&cm_id_priv->lock); 1304 1287 free: cm_free_msg(msg); 1305 1288 } 1306 1289 ··· 1310 1293 struct cm_id_private *listen_cm_id_priv, *cur_cm_id_priv; 1311 1294 struct cm_timewait_info *timewait_info; 1312 1295 struct cm_req_msg *req_msg; 1313 - unsigned long flags; 1314 1296 1315 1297 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; 1316 1298 1317 1299 /* Check for possible duplicate REQ. */ 1318 - spin_lock_irqsave(&cm.lock, flags); 1300 + spin_lock_irq(&cm.lock); 1319 1301 timewait_info = cm_insert_remote_id(cm_id_priv->timewait_info); 1320 1302 if (timewait_info) { 1321 1303 cur_cm_id_priv = cm_get_id(timewait_info->work.local_id, 1322 1304 timewait_info->work.remote_id); 1323 - spin_unlock_irqrestore(&cm.lock, flags); 1305 + spin_unlock_irq(&cm.lock); 1324 1306 if (cur_cm_id_priv) { 1325 1307 cm_dup_req_handler(work, cur_cm_id_priv); 1326 1308 cm_deref_id(cur_cm_id_priv); ··· 1331 1315 timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info); 1332 1316 if (timewait_info) { 1333 1317 cm_cleanup_timewait(cm_id_priv->timewait_info); 1334 - spin_unlock_irqrestore(&cm.lock, flags); 1318 + spin_unlock_irq(&cm.lock); 1335 1319 cm_issue_rej(work->port, work->mad_recv_wc, 1336 1320 IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REQ, 1337 1321 NULL, 0); ··· 1344 1328 req_msg->private_data); 1345 1329 if (!listen_cm_id_priv) { 1346 1330 cm_cleanup_timewait(cm_id_priv->timewait_info); 1347 - spin_unlock_irqrestore(&cm.lock, flags); 1331 + spin_unlock_irq(&cm.lock); 1348 1332 cm_issue_rej(work->port, work->mad_recv_wc, 1349 1333 IB_CM_REJ_INVALID_SERVICE_ID, CM_MSG_RESPONSE_REQ, 1350 1334 NULL, 0); ··· 1354 1338 atomic_inc(&cm_id_priv->refcount); 1355 1339 cm_id_priv->id.state = IB_CM_REQ_RCVD; 1356 1340 atomic_inc(&cm_id_priv->work_count); 1357 - spin_unlock_irqrestore(&cm.lock, flags); 1341 + spin_unlock_irq(&cm.lock); 1358 1342 out: 1359 1343 return listen_cm_id_priv; 1360 1344 } ··· 1456 1440 cm_rep_set_starting_psn(rep_msg, cpu_to_be32(param->starting_psn)); 1457 1441 rep_msg->resp_resources = param->responder_resources; 1458 1442 rep_msg->initiator_depth = param->initiator_depth; 1459 - cm_rep_set_target_ack_delay(rep_msg, param->target_ack_delay); 1443 + cm_rep_set_target_ack_delay(rep_msg, 1444 + cm_id_priv->av.port->cm_dev->ack_delay); 1460 1445 cm_rep_set_failover(rep_msg, param->failover_accepted); 1461 1446 cm_rep_set_flow_ctrl(rep_msg, param->flow_control); 1462 1447 cm_rep_set_rnr_retry_count(rep_msg, param->rnr_retry_count); ··· 1608 1591 struct cm_id_private *cm_id_priv; 1609 1592 struct cm_rep_msg *rep_msg; 1610 1593 struct ib_mad_send_buf *msg = NULL; 1611 - unsigned long flags; 1612 1594 int ret; 1613 1595 1614 1596 rep_msg = (struct cm_rep_msg *) work->mad_recv_wc->recv_buf.mad; ··· 1620 1604 if (ret) 1621 1605 goto deref; 1622 1606 1623 - spin_lock_irqsave(&cm_id_priv->lock, flags); 1607 + spin_lock_irq(&cm_id_priv->lock); 1624 1608 if (cm_id_priv->id.state == IB_CM_ESTABLISHED) 1625 1609 cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv, 1626 1610 cm_id_priv->private_data, ··· 1632 1616 cm_id_priv->private_data_len); 1633 1617 else 1634 1618 goto unlock; 1635 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1619 + spin_unlock_irq(&cm_id_priv->lock); 1636 1620 1637 1621 ret = ib_post_send_mad(msg, NULL); 1638 1622 if (ret) 1639 1623 goto free; 1640 1624 goto deref; 1641 1625 1642 - unlock: spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1626 + unlock: spin_unlock_irq(&cm_id_priv->lock); 1643 1627 free: cm_free_msg(msg); 1644 1628 deref: cm_deref_id(cm_id_priv); 1645 1629 } ··· 1648 1632 { 1649 1633 struct cm_id_private *cm_id_priv; 1650 1634 struct cm_rep_msg *rep_msg; 1651 - unsigned long flags; 1652 1635 int ret; 1653 1636 1654 1637 rep_msg = (struct cm_rep_msg *)work->mad_recv_wc->recv_buf.mad; ··· 1659 1644 1660 1645 cm_format_rep_event(work); 1661 1646 1662 - spin_lock_irqsave(&cm_id_priv->lock, flags); 1647 + spin_lock_irq(&cm_id_priv->lock); 1663 1648 switch (cm_id_priv->id.state) { 1664 1649 case IB_CM_REQ_SENT: 1665 1650 case IB_CM_MRA_REQ_RCVD: 1666 1651 break; 1667 1652 default: 1668 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1653 + spin_unlock_irq(&cm_id_priv->lock); 1669 1654 ret = -EINVAL; 1670 1655 goto error; 1671 1656 } ··· 1678 1663 /* Check for duplicate REP. */ 1679 1664 if (cm_insert_remote_id(cm_id_priv->timewait_info)) { 1680 1665 spin_unlock(&cm.lock); 1681 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1666 + spin_unlock_irq(&cm_id_priv->lock); 1682 1667 ret = -EINVAL; 1683 1668 goto error; 1684 1669 } ··· 1688 1673 &cm.remote_id_table); 1689 1674 cm_id_priv->timewait_info->inserted_remote_id = 0; 1690 1675 spin_unlock(&cm.lock); 1691 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1676 + spin_unlock_irq(&cm_id_priv->lock); 1692 1677 cm_issue_rej(work->port, work->mad_recv_wc, 1693 1678 IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REP, 1694 1679 NULL, 0); ··· 1704 1689 cm_id_priv->responder_resources = rep_msg->initiator_depth; 1705 1690 cm_id_priv->sq_psn = cm_rep_get_starting_psn(rep_msg); 1706 1691 cm_id_priv->rnr_retry_count = cm_rep_get_rnr_retry_count(rep_msg); 1692 + cm_id_priv->target_ack_delay = cm_rep_get_target_ack_delay(rep_msg); 1693 + cm_id_priv->av.timeout = 1694 + cm_ack_timeout(cm_id_priv->target_ack_delay, 1695 + cm_id_priv->av.timeout - 1); 1696 + cm_id_priv->alt_av.timeout = 1697 + cm_ack_timeout(cm_id_priv->target_ack_delay, 1698 + cm_id_priv->alt_av.timeout - 1); 1707 1699 1708 1700 /* todo: handle peer_to_peer */ 1709 1701 ··· 1718 1696 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1719 1697 if (!ret) 1720 1698 list_add_tail(&work->list, &cm_id_priv->work_list); 1721 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1699 + spin_unlock_irq(&cm_id_priv->lock); 1722 1700 1723 1701 if (ret) 1724 1702 cm_process_work(cm_id_priv, work); ··· 1734 1712 static int cm_establish_handler(struct cm_work *work) 1735 1713 { 1736 1714 struct cm_id_private *cm_id_priv; 1737 - unsigned long flags; 1738 1715 int ret; 1739 1716 1740 1717 /* See comment in cm_establish about lookup. */ ··· 1741 1720 if (!cm_id_priv) 1742 1721 return -EINVAL; 1743 1722 1744 - spin_lock_irqsave(&cm_id_priv->lock, flags); 1723 + spin_lock_irq(&cm_id_priv->lock); 1745 1724 if (cm_id_priv->id.state != IB_CM_ESTABLISHED) { 1746 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1725 + spin_unlock_irq(&cm_id_priv->lock); 1747 1726 goto out; 1748 1727 } 1749 1728 ··· 1751 1730 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1752 1731 if (!ret) 1753 1732 list_add_tail(&work->list, &cm_id_priv->work_list); 1754 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1733 + spin_unlock_irq(&cm_id_priv->lock); 1755 1734 1756 1735 if (ret) 1757 1736 cm_process_work(cm_id_priv, work); ··· 1767 1746 { 1768 1747 struct cm_id_private *cm_id_priv; 1769 1748 struct cm_rtu_msg *rtu_msg; 1770 - unsigned long flags; 1771 1749 int ret; 1772 1750 1773 1751 rtu_msg = (struct cm_rtu_msg *)work->mad_recv_wc->recv_buf.mad; ··· 1777 1757 1778 1758 work->cm_event.private_data = &rtu_msg->private_data; 1779 1759 1780 - spin_lock_irqsave(&cm_id_priv->lock, flags); 1760 + spin_lock_irq(&cm_id_priv->lock); 1781 1761 if (cm_id_priv->id.state != IB_CM_REP_SENT && 1782 1762 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) { 1783 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1763 + spin_unlock_irq(&cm_id_priv->lock); 1784 1764 goto out; 1785 1765 } 1786 1766 cm_id_priv->id.state = IB_CM_ESTABLISHED; ··· 1789 1769 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1790 1770 if (!ret) 1791 1771 list_add_tail(&work->list, &cm_id_priv->work_list); 1792 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1772 + spin_unlock_irq(&cm_id_priv->lock); 1793 1773 1794 1774 if (ret) 1795 1775 cm_process_work(cm_id_priv, work); ··· 1952 1932 struct cm_id_private *cm_id_priv; 1953 1933 struct cm_dreq_msg *dreq_msg; 1954 1934 struct ib_mad_send_buf *msg = NULL; 1955 - unsigned long flags; 1956 1935 int ret; 1957 1936 1958 1937 dreq_msg = (struct cm_dreq_msg *)work->mad_recv_wc->recv_buf.mad; ··· 1964 1945 1965 1946 work->cm_event.private_data = &dreq_msg->private_data; 1966 1947 1967 - spin_lock_irqsave(&cm_id_priv->lock, flags); 1948 + spin_lock_irq(&cm_id_priv->lock); 1968 1949 if (cm_id_priv->local_qpn != cm_dreq_get_remote_qpn(dreq_msg)) 1969 1950 goto unlock; 1970 1951 ··· 1983 1964 cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv, 1984 1965 cm_id_priv->private_data, 1985 1966 cm_id_priv->private_data_len); 1986 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1967 + spin_unlock_irq(&cm_id_priv->lock); 1987 1968 1988 1969 if (ib_post_send_mad(msg, NULL)) 1989 1970 cm_free_msg(msg); ··· 1996 1977 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1997 1978 if (!ret) 1998 1979 list_add_tail(&work->list, &cm_id_priv->work_list); 1999 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1980 + spin_unlock_irq(&cm_id_priv->lock); 2000 1981 2001 1982 if (ret) 2002 1983 cm_process_work(cm_id_priv, work); ··· 2004 1985 cm_deref_id(cm_id_priv); 2005 1986 return 0; 2006 1987 2007 - unlock: spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1988 + unlock: spin_unlock_irq(&cm_id_priv->lock); 2008 1989 deref: cm_deref_id(cm_id_priv); 2009 1990 return -EINVAL; 2010 1991 } ··· 2013 1994 { 2014 1995 struct cm_id_private *cm_id_priv; 2015 1996 struct cm_drep_msg *drep_msg; 2016 - unsigned long flags; 2017 1997 int ret; 2018 1998 2019 1999 drep_msg = (struct cm_drep_msg *)work->mad_recv_wc->recv_buf.mad; ··· 2023 2005 2024 2006 work->cm_event.private_data = &drep_msg->private_data; 2025 2007 2026 - spin_lock_irqsave(&cm_id_priv->lock, flags); 2008 + spin_lock_irq(&cm_id_priv->lock); 2027 2009 if (cm_id_priv->id.state != IB_CM_DREQ_SENT && 2028 2010 cm_id_priv->id.state != IB_CM_DREQ_RCVD) { 2029 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2011 + spin_unlock_irq(&cm_id_priv->lock); 2030 2012 goto out; 2031 2013 } 2032 2014 cm_enter_timewait(cm_id_priv); ··· 2035 2017 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2036 2018 if (!ret) 2037 2019 list_add_tail(&work->list, &cm_id_priv->work_list); 2038 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2020 + spin_unlock_irq(&cm_id_priv->lock); 2039 2021 2040 2022 if (ret) 2041 2023 cm_process_work(cm_id_priv, work); ··· 2125 2107 { 2126 2108 struct cm_timewait_info *timewait_info; 2127 2109 struct cm_id_private *cm_id_priv; 2128 - unsigned long flags; 2129 2110 __be32 remote_id; 2130 2111 2131 2112 remote_id = rej_msg->local_comm_id; 2132 2113 2133 2114 if (__be16_to_cpu(rej_msg->reason) == IB_CM_REJ_TIMEOUT) { 2134 - spin_lock_irqsave(&cm.lock, flags); 2115 + spin_lock_irq(&cm.lock); 2135 2116 timewait_info = cm_find_remote_id( *((__be64 *) rej_msg->ari), 2136 2117 remote_id); 2137 2118 if (!timewait_info) { 2138 - spin_unlock_irqrestore(&cm.lock, flags); 2119 + spin_unlock_irq(&cm.lock); 2139 2120 return NULL; 2140 2121 } 2141 2122 cm_id_priv = idr_find(&cm.local_id_table, (__force int) ··· 2146 2129 else 2147 2130 cm_id_priv = NULL; 2148 2131 } 2149 - spin_unlock_irqrestore(&cm.lock, flags); 2132 + spin_unlock_irq(&cm.lock); 2150 2133 } else if (cm_rej_get_msg_rejected(rej_msg) == CM_MSG_RESPONSE_REQ) 2151 2134 cm_id_priv = cm_acquire_id(rej_msg->remote_comm_id, 0); 2152 2135 else ··· 2159 2142 { 2160 2143 struct cm_id_private *cm_id_priv; 2161 2144 struct cm_rej_msg *rej_msg; 2162 - unsigned long flags; 2163 2145 int ret; 2164 2146 2165 2147 rej_msg = (struct cm_rej_msg *)work->mad_recv_wc->recv_buf.mad; ··· 2168 2152 2169 2153 cm_format_rej_event(work); 2170 2154 2171 - spin_lock_irqsave(&cm_id_priv->lock, flags); 2155 + spin_lock_irq(&cm_id_priv->lock); 2172 2156 switch (cm_id_priv->id.state) { 2173 2157 case IB_CM_REQ_SENT: 2174 2158 case IB_CM_MRA_REQ_RCVD: ··· 2192 2176 cm_enter_timewait(cm_id_priv); 2193 2177 break; 2194 2178 default: 2195 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2179 + spin_unlock_irq(&cm_id_priv->lock); 2196 2180 ret = -EINVAL; 2197 2181 goto out; 2198 2182 } ··· 2200 2184 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2201 2185 if (!ret) 2202 2186 list_add_tail(&work->list, &cm_id_priv->work_list); 2203 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2187 + spin_unlock_irq(&cm_id_priv->lock); 2204 2188 2205 2189 if (ret) 2206 2190 cm_process_work(cm_id_priv, work); ··· 2311 2295 { 2312 2296 struct cm_id_private *cm_id_priv; 2313 2297 struct cm_mra_msg *mra_msg; 2314 - unsigned long flags; 2315 2298 int timeout, ret; 2316 2299 2317 2300 mra_msg = (struct cm_mra_msg *)work->mad_recv_wc->recv_buf.mad; ··· 2322 2307 work->cm_event.param.mra_rcvd.service_timeout = 2323 2308 cm_mra_get_service_timeout(mra_msg); 2324 2309 timeout = cm_convert_to_ms(cm_mra_get_service_timeout(mra_msg)) + 2325 - cm_convert_to_ms(cm_id_priv->av.packet_life_time); 2310 + cm_convert_to_ms(cm_id_priv->av.timeout); 2326 2311 2327 - spin_lock_irqsave(&cm_id_priv->lock, flags); 2312 + spin_lock_irq(&cm_id_priv->lock); 2328 2313 switch (cm_id_priv->id.state) { 2329 2314 case IB_CM_REQ_SENT: 2330 2315 if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REQ || ··· 2357 2342 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2358 2343 if (!ret) 2359 2344 list_add_tail(&work->list, &cm_id_priv->work_list); 2360 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2345 + spin_unlock_irq(&cm_id_priv->lock); 2361 2346 2362 2347 if (ret) 2363 2348 cm_process_work(cm_id_priv, work); ··· 2365 2350 cm_deref_id(cm_id_priv); 2366 2351 return 0; 2367 2352 out: 2368 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2353 + spin_unlock_irq(&cm_id_priv->lock); 2369 2354 cm_deref_id(cm_id_priv); 2370 2355 return -EINVAL; 2371 2356 } ··· 2394 2379 cm_lap_set_sl(lap_msg, alternate_path->sl); 2395 2380 cm_lap_set_subnet_local(lap_msg, 1); /* local only... */ 2396 2381 cm_lap_set_local_ack_timeout(lap_msg, 2397 - min(31, alternate_path->packet_life_time + 1)); 2382 + cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay, 2383 + alternate_path->packet_life_time)); 2398 2384 2399 2385 if (private_data && private_data_len) 2400 2386 memcpy(lap_msg->private_data, private_data, private_data_len); ··· 2426 2410 ret = cm_init_av_by_path(alternate_path, &cm_id_priv->alt_av); 2427 2411 if (ret) 2428 2412 goto out; 2413 + cm_id_priv->alt_av.timeout = 2414 + cm_ack_timeout(cm_id_priv->target_ack_delay, 2415 + cm_id_priv->alt_av.timeout - 1); 2429 2416 2430 2417 ret = cm_alloc_msg(cm_id_priv, &msg); 2431 2418 if (ret) ··· 2484 2465 struct cm_lap_msg *lap_msg; 2485 2466 struct ib_cm_lap_event_param *param; 2486 2467 struct ib_mad_send_buf *msg = NULL; 2487 - unsigned long flags; 2488 2468 int ret; 2489 2469 2490 2470 /* todo: verify LAP request and send reject APR if invalid. */ ··· 2498 2480 cm_format_path_from_lap(cm_id_priv, param->alternate_path, lap_msg); 2499 2481 work->cm_event.private_data = &lap_msg->private_data; 2500 2482 2501 - spin_lock_irqsave(&cm_id_priv->lock, flags); 2483 + spin_lock_irq(&cm_id_priv->lock); 2502 2484 if (cm_id_priv->id.state != IB_CM_ESTABLISHED) 2503 2485 goto unlock; 2504 2486 ··· 2515 2497 cm_id_priv->service_timeout, 2516 2498 cm_id_priv->private_data, 2517 2499 cm_id_priv->private_data_len); 2518 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2500 + spin_unlock_irq(&cm_id_priv->lock); 2519 2501 2520 2502 if (ib_post_send_mad(msg, NULL)) 2521 2503 cm_free_msg(msg); ··· 2533 2515 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2534 2516 if (!ret) 2535 2517 list_add_tail(&work->list, &cm_id_priv->work_list); 2536 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2518 + spin_unlock_irq(&cm_id_priv->lock); 2537 2519 2538 2520 if (ret) 2539 2521 cm_process_work(cm_id_priv, work); ··· 2541 2523 cm_deref_id(cm_id_priv); 2542 2524 return 0; 2543 2525 2544 - unlock: spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2526 + unlock: spin_unlock_irq(&cm_id_priv->lock); 2545 2527 deref: cm_deref_id(cm_id_priv); 2546 2528 return -EINVAL; 2547 2529 } ··· 2616 2598 { 2617 2599 struct cm_id_private *cm_id_priv; 2618 2600 struct cm_apr_msg *apr_msg; 2619 - unsigned long flags; 2620 2601 int ret; 2621 2602 2622 2603 apr_msg = (struct cm_apr_msg *)work->mad_recv_wc->recv_buf.mad; ··· 2629 2612 work->cm_event.param.apr_rcvd.info_len = apr_msg->info_length; 2630 2613 work->cm_event.private_data = &apr_msg->private_data; 2631 2614 2632 - spin_lock_irqsave(&cm_id_priv->lock, flags); 2615 + spin_lock_irq(&cm_id_priv->lock); 2633 2616 if (cm_id_priv->id.state != IB_CM_ESTABLISHED || 2634 2617 (cm_id_priv->id.lap_state != IB_CM_LAP_SENT && 2635 2618 cm_id_priv->id.lap_state != IB_CM_MRA_LAP_RCVD)) { 2636 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2619 + spin_unlock_irq(&cm_id_priv->lock); 2637 2620 goto out; 2638 2621 } 2639 2622 cm_id_priv->id.lap_state = IB_CM_LAP_IDLE; ··· 2643 2626 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2644 2627 if (!ret) 2645 2628 list_add_tail(&work->list, &cm_id_priv->work_list); 2646 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2629 + spin_unlock_irq(&cm_id_priv->lock); 2647 2630 2648 2631 if (ret) 2649 2632 cm_process_work(cm_id_priv, work); ··· 2778 2761 struct cm_id_private *cm_id_priv, *cur_cm_id_priv; 2779 2762 struct cm_sidr_req_msg *sidr_req_msg; 2780 2763 struct ib_wc *wc; 2781 - unsigned long flags; 2782 2764 2783 2765 cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL); 2784 2766 if (IS_ERR(cm_id)) ··· 2794 2778 work->mad_recv_wc->recv_buf.grh, 2795 2779 &cm_id_priv->av); 2796 2780 cm_id_priv->id.remote_id = sidr_req_msg->request_id; 2797 - cm_id_priv->id.state = IB_CM_SIDR_REQ_RCVD; 2798 2781 cm_id_priv->tid = sidr_req_msg->hdr.tid; 2799 2782 atomic_inc(&cm_id_priv->work_count); 2800 2783 2801 - spin_lock_irqsave(&cm.lock, flags); 2784 + spin_lock_irq(&cm.lock); 2802 2785 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv); 2803 2786 if (cur_cm_id_priv) { 2804 - spin_unlock_irqrestore(&cm.lock, flags); 2787 + spin_unlock_irq(&cm.lock); 2805 2788 goto out; /* Duplicate message. */ 2806 2789 } 2790 + cm_id_priv->id.state = IB_CM_SIDR_REQ_RCVD; 2807 2791 cur_cm_id_priv = cm_find_listen(cm_id->device, 2808 2792 sidr_req_msg->service_id, 2809 2793 sidr_req_msg->private_data); 2810 2794 if (!cur_cm_id_priv) { 2811 - rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); 2812 - spin_unlock_irqrestore(&cm.lock, flags); 2813 - /* todo: reply with no match */ 2795 + spin_unlock_irq(&cm.lock); 2796 + cm_reject_sidr_req(cm_id_priv, IB_SIDR_UNSUPPORTED); 2814 2797 goto out; /* No match. */ 2815 2798 } 2816 2799 atomic_inc(&cur_cm_id_priv->refcount); 2817 - spin_unlock_irqrestore(&cm.lock, flags); 2800 + spin_unlock_irq(&cm.lock); 2818 2801 2819 2802 cm_id_priv->id.cm_handler = cur_cm_id_priv->id.cm_handler; 2820 2803 cm_id_priv->id.context = cur_cm_id_priv->id.context; ··· 2914 2899 { 2915 2900 struct cm_sidr_rep_msg *sidr_rep_msg; 2916 2901 struct cm_id_private *cm_id_priv; 2917 - unsigned long flags; 2918 2902 2919 2903 sidr_rep_msg = (struct cm_sidr_rep_msg *) 2920 2904 work->mad_recv_wc->recv_buf.mad; ··· 2921 2907 if (!cm_id_priv) 2922 2908 return -EINVAL; /* Unmatched reply. */ 2923 2909 2924 - spin_lock_irqsave(&cm_id_priv->lock, flags); 2910 + spin_lock_irq(&cm_id_priv->lock); 2925 2911 if (cm_id_priv->id.state != IB_CM_SIDR_REQ_SENT) { 2926 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2912 + spin_unlock_irq(&cm_id_priv->lock); 2927 2913 goto out; 2928 2914 } 2929 2915 cm_id_priv->id.state = IB_CM_IDLE; 2930 2916 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); 2931 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2917 + spin_unlock_irq(&cm_id_priv->lock); 2932 2918 2933 2919 cm_format_sidr_rep_event(work); 2934 2920 cm_process_work(cm_id_priv, work); ··· 2944 2930 struct cm_id_private *cm_id_priv; 2945 2931 struct ib_cm_event cm_event; 2946 2932 enum ib_cm_state state; 2947 - unsigned long flags; 2948 2933 int ret; 2949 2934 2950 2935 memset(&cm_event, 0, sizeof cm_event); 2951 2936 cm_id_priv = msg->context[0]; 2952 2937 2953 2938 /* Discard old sends or ones without a response. */ 2954 - spin_lock_irqsave(&cm_id_priv->lock, flags); 2939 + spin_lock_irq(&cm_id_priv->lock); 2955 2940 state = (enum ib_cm_state) (unsigned long) msg->context[1]; 2956 2941 if (msg != cm_id_priv->msg || state != cm_id_priv->id.state) 2957 2942 goto discard; ··· 2977 2964 default: 2978 2965 goto discard; 2979 2966 } 2980 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2967 + spin_unlock_irq(&cm_id_priv->lock); 2981 2968 cm_event.param.send_status = wc_status; 2982 2969 2983 2970 /* No other events can occur on the cm_id at this point. */ ··· 2987 2974 ib_destroy_cm_id(&cm_id_priv->id); 2988 2975 return; 2989 2976 discard: 2990 - spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2977 + spin_unlock_irq(&cm_id_priv->lock); 2991 2978 cm_free_msg(msg); 2992 2979 } 2993 2980 ··· 3282 3269 *qp_attr_mask |= IB_QP_ALT_PATH; 3283 3270 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num; 3284 3271 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index; 3285 - qp_attr->alt_timeout = 3286 - cm_id_priv->alt_av.packet_life_time + 1; 3272 + qp_attr->alt_timeout = cm_id_priv->alt_av.timeout; 3287 3273 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr; 3288 3274 } 3289 3275 ret = 0; ··· 3320 3308 *qp_attr_mask |= IB_QP_TIMEOUT | IB_QP_RETRY_CNT | 3321 3309 IB_QP_RNR_RETRY | 3322 3310 IB_QP_MAX_QP_RD_ATOMIC; 3323 - qp_attr->timeout = 3324 - cm_id_priv->av.packet_life_time + 1; 3311 + qp_attr->timeout = cm_id_priv->av.timeout; 3325 3312 qp_attr->retry_cnt = cm_id_priv->retry_count; 3326 3313 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count; 3327 3314 qp_attr->max_rd_atomic = ··· 3334 3323 *qp_attr_mask = IB_QP_ALT_PATH | IB_QP_PATH_MIG_STATE; 3335 3324 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num; 3336 3325 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index; 3337 - qp_attr->alt_timeout = 3338 - cm_id_priv->alt_av.packet_life_time + 1; 3326 + qp_attr->alt_timeout = cm_id_priv->alt_av.timeout; 3339 3327 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr; 3340 3328 qp_attr->path_mig_state = IB_MIG_REARM; 3341 3329 } ··· 3374 3364 } 3375 3365 EXPORT_SYMBOL(ib_cm_init_qp_attr); 3376 3366 3367 + void cm_get_ack_delay(struct cm_device *cm_dev) 3368 + { 3369 + struct ib_device_attr attr; 3370 + 3371 + if (ib_query_device(cm_dev->device, &attr)) 3372 + cm_dev->ack_delay = 0; /* acks will rely on packet life time */ 3373 + else 3374 + cm_dev->ack_delay = attr.local_ca_ack_delay; 3375 + } 3376 + 3377 3377 static void cm_add_one(struct ib_device *device) 3378 3378 { 3379 3379 struct cm_device *cm_dev; ··· 3408 3388 return; 3409 3389 3410 3390 cm_dev->device = device; 3391 + cm_get_ack_delay(cm_dev); 3411 3392 3412 3393 set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); 3413 3394 for (i = 1; i <= device->phys_port_cnt; i++) {
+1
drivers/infiniband/core/cm_msgs.h
··· 35 35 #define CM_MSGS_H 36 36 37 37 #include <rdma/ib_mad.h> 38 + #include <rdma/ib_cm.h> 38 39 39 40 /* 40 41 * Parameters to routines below should be in network-byte order, and values
-1
drivers/infiniband/core/cma.c
··· 2326 2326 rep.private_data_len = conn_param->private_data_len; 2327 2327 rep.responder_resources = conn_param->responder_resources; 2328 2328 rep.initiator_depth = conn_param->initiator_depth; 2329 - rep.target_ack_delay = CMA_CM_RESPONSE_TIMEOUT; 2330 2329 rep.failover_accepted = 0; 2331 2330 rep.flow_control = conn_param->flow_control; 2332 2331 rep.rnr_retry_count = conn_param->rnr_retry_count;
+41 -9
drivers/infiniband/core/mad.c
··· 675 675 struct ib_mad_port_private *port_priv; 676 676 struct ib_mad_agent_private *recv_mad_agent = NULL; 677 677 struct ib_device *device = mad_agent_priv->agent.device; 678 - u8 port_num = mad_agent_priv->agent.port_num; 678 + u8 port_num; 679 679 struct ib_wc mad_wc; 680 680 struct ib_send_wr *send_wr = &mad_send_wr->send_wr; 681 + 682 + if (device->node_type == RDMA_NODE_IB_SWITCH && 683 + smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 684 + port_num = send_wr->wr.ud.port_num; 685 + else 686 + port_num = mad_agent_priv->agent.port_num; 681 687 682 688 /* 683 689 * Directed route handling starts if the initial LID routed part of ··· 1845 1839 struct ib_mad_private *recv, *response; 1846 1840 struct ib_mad_list_head *mad_list; 1847 1841 struct ib_mad_agent_private *mad_agent; 1842 + int port_num; 1848 1843 1849 1844 response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL); 1850 1845 if (!response) ··· 1879 1872 if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num)) 1880 1873 goto out; 1881 1874 1875 + if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) 1876 + port_num = wc->port_num; 1877 + else 1878 + port_num = port_priv->port_num; 1879 + 1882 1880 if (recv->mad.mad.mad_hdr.mgmt_class == 1883 1881 IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) { 1882 + enum smi_forward_action retsmi; 1883 + 1884 1884 if (smi_handle_dr_smp_recv(&recv->mad.smp, 1885 1885 port_priv->device->node_type, 1886 - port_priv->port_num, 1886 + port_num, 1887 1887 port_priv->device->phys_port_cnt) == 1888 1888 IB_SMI_DISCARD) 1889 1889 goto out; 1890 1890 1891 - if (smi_check_forward_dr_smp(&recv->mad.smp) == IB_SMI_LOCAL) 1891 + retsmi = smi_check_forward_dr_smp(&recv->mad.smp); 1892 + if (retsmi == IB_SMI_LOCAL) 1892 1893 goto local; 1893 1894 1894 - if (smi_handle_dr_smp_send(&recv->mad.smp, 1895 - port_priv->device->node_type, 1896 - port_priv->port_num) == IB_SMI_DISCARD) 1897 - goto out; 1895 + if (retsmi == IB_SMI_SEND) { /* don't forward */ 1896 + if (smi_handle_dr_smp_send(&recv->mad.smp, 1897 + port_priv->device->node_type, 1898 + port_num) == IB_SMI_DISCARD) 1899 + goto out; 1898 1900 1899 - if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD) 1901 + if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD) 1902 + goto out; 1903 + } else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) { 1904 + /* forward case for switches */ 1905 + memcpy(response, recv, sizeof(*response)); 1906 + response->header.recv_wc.wc = &response->header.wc; 1907 + response->header.recv_wc.recv_buf.mad = &response->mad.mad; 1908 + response->header.recv_wc.recv_buf.grh = &response->grh; 1909 + 1910 + if (!agent_send_response(&response->mad.mad, 1911 + &response->grh, wc, 1912 + port_priv->device, 1913 + smi_get_fwd_port(&recv->mad.smp), 1914 + qp_info->qp->qp_num)) 1915 + response = NULL; 1916 + 1900 1917 goto out; 1918 + } 1901 1919 } 1902 1920 1903 1921 local: ··· 1951 1919 agent_send_response(&response->mad.mad, 1952 1920 &recv->grh, wc, 1953 1921 port_priv->device, 1954 - port_priv->port_num, 1922 + port_num, 1955 1923 qp_info->qp->qp_num); 1956 1924 goto out; 1957 1925 }
+1 -1
drivers/infiniband/core/multicast.c
··· 1 1 /* 2 - * Copyright (c) 2006 Intel Corporation.  All rights reserved. 2 + * Copyright (c) 2006 Intel Corporation. All rights reserved. 3 3 * 4 4 * This software is available to you under a choice of one of two 5 5 * licenses. You may choose to be licensed under the terms of the GNU
+1 -1
drivers/infiniband/core/sa.h
··· 1 1 /* 2 2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 3 - * Copyright (c) 2005 Voltaire, Inc.  All rights reserved. 3 + * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 4 4 * Copyright (c) 2006 Intel Corporation. All rights reserved. 5 5 * 6 6 * This software is available to you under a choice of one of two
+51 -36
drivers/infiniband/core/sa_query.c
··· 1 1 /* 2 2 * Copyright (c) 2004 Topspin Communications. All rights reserved. 3 - * Copyright (c) 2005 Voltaire, Inc.  All rights reserved. 3 + * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 4 4 * Copyright (c) 2006 Intel Corporation. All rights reserved. 5 5 * 6 6 * This software is available to you under a choice of one of two ··· 56 56 struct ib_sa_sm_ah { 57 57 struct ib_ah *ah; 58 58 struct kref ref; 59 + u16 pkey_index; 59 60 u8 src_path_mask; 60 61 }; 61 62 ··· 383 382 kref_init(&new_ah->ref); 384 383 new_ah->src_path_mask = (1 << port_attr.lmc) - 1; 385 384 385 + new_ah->pkey_index = 0; 386 + if (ib_find_pkey(port->agent->device, port->port_num, 387 + IB_DEFAULT_PKEY_FULL, &new_ah->pkey_index) && 388 + ib_find_pkey(port->agent->device, port->port_num, 389 + IB_DEFAULT_PKEY_PARTIAL, &new_ah->pkey_index)) 390 + printk(KERN_ERR "Couldn't find index for default PKey\n"); 391 + 386 392 memset(&ah_attr, 0, sizeof ah_attr); 387 393 ah_attr.dlid = port_attr.sm_lid; 388 394 ah_attr.sl = port_attr.sm_sl; ··· 520 512 } 521 513 EXPORT_SYMBOL(ib_init_ah_from_path); 522 514 515 + static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask) 516 + { 517 + unsigned long flags; 518 + 519 + spin_lock_irqsave(&query->port->ah_lock, flags); 520 + kref_get(&query->port->sm_ah->ref); 521 + query->sm_ah = query->port->sm_ah; 522 + spin_unlock_irqrestore(&query->port->ah_lock, flags); 523 + 524 + query->mad_buf = ib_create_send_mad(query->port->agent, 1, 525 + query->sm_ah->pkey_index, 526 + 0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA, 527 + gfp_mask); 528 + if (!query->mad_buf) { 529 + kref_put(&query->sm_ah->ref, free_sm_ah); 530 + return -ENOMEM; 531 + } 532 + 533 + query->mad_buf->ah = query->sm_ah->ah; 534 + 535 + return 0; 536 + } 537 + 538 + static void free_mad(struct ib_sa_query *query) 539 + { 540 + ib_free_send_mad(query->mad_buf); 541 + kref_put(&query->sm_ah->ref, free_sm_ah); 542 + } 543 + 523 544 static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent) 524 545 { 525 546 unsigned long flags; ··· 585 548 query->mad_buf->context[0] = query; 586 549 query->id = id; 587 550 588 - spin_lock_irqsave(&query->port->ah_lock, flags); 589 - kref_get(&query->port->sm_ah->ref); 590 - query->sm_ah = query->port->sm_ah; 591 - spin_unlock_irqrestore(&query->port->ah_lock, flags); 592 - 593 - query->mad_buf->ah = query->sm_ah->ah; 594 - 595 551 ret = ib_post_send_mad(query->mad_buf, NULL); 596 552 if (ret) { 597 553 spin_lock_irqsave(&idr_lock, flags); 598 554 idr_remove(&query_idr, id); 599 555 spin_unlock_irqrestore(&idr_lock, flags); 600 - 601 - kref_put(&query->sm_ah->ref, free_sm_ah); 602 556 } 603 557 604 558 /* ··· 675 647 if (!query) 676 648 return -ENOMEM; 677 649 678 - query->sa_query.mad_buf = ib_create_send_mad(agent, 1, 0, 679 - 0, IB_MGMT_SA_HDR, 680 - IB_MGMT_SA_DATA, gfp_mask); 681 - if (!query->sa_query.mad_buf) { 682 - ret = -ENOMEM; 650 + query->sa_query.port = port; 651 + ret = alloc_mad(&query->sa_query, gfp_mask); 652 + if (ret) 683 653 goto err1; 684 - } 685 654 686 655 ib_sa_client_get(client); 687 656 query->sa_query.client = client; ··· 690 665 691 666 query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL; 692 667 query->sa_query.release = ib_sa_path_rec_release; 693 - query->sa_query.port = port; 694 668 mad->mad_hdr.method = IB_MGMT_METHOD_GET; 695 669 mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_PATH_REC); 696 670 mad->sa_hdr.comp_mask = comp_mask; ··· 707 683 err2: 708 684 *sa_query = NULL; 709 685 ib_sa_client_put(query->sa_query.client); 710 - ib_free_send_mad(query->sa_query.mad_buf); 686 + free_mad(&query->sa_query); 711 687 712 688 err1: 713 689 kfree(query); ··· 797 773 if (!query) 798 774 return -ENOMEM; 799 775 800 - query->sa_query.mad_buf = ib_create_send_mad(agent, 1, 0, 801 - 0, IB_MGMT_SA_HDR, 802 - IB_MGMT_SA_DATA, gfp_mask); 803 - if (!query->sa_query.mad_buf) { 804 - ret = -ENOMEM; 776 + query->sa_query.port = port; 777 + ret = alloc_mad(&query->sa_query, gfp_mask); 778 + if (ret) 805 779 goto err1; 806 - } 807 780 808 781 ib_sa_client_get(client); 809 782 query->sa_query.client = client; ··· 812 791 813 792 query->sa_query.callback = callback ? ib_sa_service_rec_callback : NULL; 814 793 query->sa_query.release = ib_sa_service_rec_release; 815 - query->sa_query.port = port; 816 794 mad->mad_hdr.method = method; 817 795 mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_SERVICE_REC); 818 796 mad->sa_hdr.comp_mask = comp_mask; ··· 830 810 err2: 831 811 *sa_query = NULL; 832 812 ib_sa_client_put(query->sa_query.client); 833 - ib_free_send_mad(query->sa_query.mad_buf); 813 + free_mad(&query->sa_query); 834 814 835 815 err1: 836 816 kfree(query); ··· 889 869 if (!query) 890 870 return -ENOMEM; 891 871 892 - query->sa_query.mad_buf = ib_create_send_mad(agent, 1, 0, 893 - 0, IB_MGMT_SA_HDR, 894 - IB_MGMT_SA_DATA, gfp_mask); 895 - if (!query->sa_query.mad_buf) { 896 - ret = -ENOMEM; 872 + query->sa_query.port = port; 873 + ret = alloc_mad(&query->sa_query, gfp_mask); 874 + if (ret) 897 875 goto err1; 898 - } 899 876 900 877 ib_sa_client_get(client); 901 878 query->sa_query.client = client; ··· 904 887 905 888 query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL; 906 889 query->sa_query.release = ib_sa_mcmember_rec_release; 907 - query->sa_query.port = port; 908 890 mad->mad_hdr.method = method; 909 891 mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_MC_MEMBER_REC); 910 892 mad->sa_hdr.comp_mask = comp_mask; ··· 922 906 err2: 923 907 *sa_query = NULL; 924 908 ib_sa_client_put(query->sa_query.client); 925 - ib_free_send_mad(query->sa_query.mad_buf); 909 + free_mad(&query->sa_query); 926 910 927 911 err1: 928 912 kfree(query); ··· 955 939 idr_remove(&query_idr, query->id); 956 940 spin_unlock_irqrestore(&idr_lock, flags); 957 941 958 - ib_free_send_mad(mad_send_wc->send_buf); 959 - kref_put(&query->sm_ah->ref, free_sm_ah); 942 + free_mad(query); 960 943 ib_sa_client_put(query->client); 961 944 query->release(query); 962 945 }
+13 -3
drivers/infiniband/core/smi.c
··· 192 192 } 193 193 /* smp->hop_ptr updated when sending */ 194 194 return (node_type == RDMA_NODE_IB_SWITCH ? 195 - IB_SMI_HANDLE: IB_SMI_DISCARD); 195 + IB_SMI_HANDLE : IB_SMI_DISCARD); 196 196 } 197 197 198 198 /* C14-13:4 -- hop_ptr = 0 -> give to SM */ ··· 211 211 if (!ib_get_smp_direction(smp)) { 212 212 /* C14-9:2 -- intermediate hop */ 213 213 if (hop_ptr && hop_ptr < hop_cnt) 214 - return IB_SMI_SEND; 214 + return IB_SMI_FORWARD; 215 215 216 216 /* C14-9:3 -- at the end of the DR segment of path */ 217 217 if (hop_ptr == hop_cnt) ··· 224 224 } else { 225 225 /* C14-13:2 -- intermediate hop */ 226 226 if (2 <= hop_ptr && hop_ptr <= hop_cnt) 227 - return IB_SMI_SEND; 227 + return IB_SMI_FORWARD; 228 228 229 229 /* C14-13:3 -- at the end of the DR segment of path */ 230 230 if (hop_ptr == 1) ··· 232 232 IB_SMI_SEND : IB_SMI_LOCAL); 233 233 } 234 234 return IB_SMI_LOCAL; 235 + } 236 + 237 + /* 238 + * Return the forwarding port number from initial_path for outgoing SMP and 239 + * from return_path for returning SMP 240 + */ 241 + int smi_get_fwd_port(struct ib_smp *smp) 242 + { 243 + return (!ib_get_smp_direction(smp) ? smp->initial_path[smp->hop_ptr+1] : 244 + smp->return_path[smp->hop_ptr-1]); 235 245 }
+2
drivers/infiniband/core/smi.h
··· 48 48 enum smi_forward_action { 49 49 IB_SMI_LOCAL, /* SMP should be completed up the stack */ 50 50 IB_SMI_SEND, /* received DR SMP should be forwarded to the send queue */ 51 + IB_SMI_FORWARD /* SMP should be forwarded (for switches only) */ 51 52 }; 52 53 53 54 enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type, 54 55 int port_num, int phys_port_cnt); 56 + int smi_get_fwd_port(struct ib_smp *smp); 55 57 extern enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp); 56 58 extern enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp, 57 59 u8 node_type, int port_num);
+1 -1
drivers/infiniband/core/sysfs.c
··· 311 311 return sprintf(buf, "N/A (no PMA)\n"); 312 312 313 313 in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); 314 - out_mad = kmalloc(sizeof *in_mad, GFP_KERNEL); 314 + out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); 315 315 if (!in_mad || !out_mad) { 316 316 ret = -ENOMEM; 317 317 goto out;
-1
drivers/infiniband/core/ucm.c
··· 823 823 param.private_data_len = cmd.len; 824 824 param.responder_resources = cmd.responder_resources; 825 825 param.initiator_depth = cmd.initiator_depth; 826 - param.target_ack_delay = cmd.target_ack_delay; 827 826 param.failover_accepted = cmd.failover_accepted; 828 827 param.flow_control = cmd.flow_control; 829 828 param.rnr_retry_count = cmd.rnr_retry_count;
+1
drivers/infiniband/core/umem.c
··· 121 121 122 122 cur_base = addr & PAGE_MASK; 123 123 124 + ret = 0; 124 125 while (npages) { 125 126 ret = get_user_pages(current, current->mm, cur_base, 126 127 min_t(int, npages,
+1 -1
drivers/infiniband/hw/amso1100/Kconfig
··· 1 1 config INFINIBAND_AMSO1100 2 2 tristate "Ammasso 1100 HCA support" 3 - depends on PCI && INET && INFINIBAND 3 + depends on PCI && INET 4 4 ---help--- 5 5 This is a low-level driver for the Ammasso 1100 host 6 6 channel adapter (HCA).
+1 -1
drivers/infiniband/hw/cxgb3/Kconfig
··· 1 1 config INFINIBAND_CXGB3 2 2 tristate "Chelsio RDMA Driver" 3 - depends on CHELSIO_T3 && INFINIBAND && INET 3 + depends on CHELSIO_T3 && INET 4 4 select GENERIC_ALLOCATOR 5 5 ---help--- 6 6 This is an iWARP/RDMA driver for the Chelsio T3 1GbE and
+3 -3
drivers/infiniband/hw/cxgb3/cxio_hal.c
··· 144 144 } 145 145 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); 146 146 memset(wqe, 0, sizeof(*wqe)); 147 - build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 3, 1, qpid, 7); 147 + build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 3, 0, qpid, 7); 148 148 wqe->flags = cpu_to_be32(MODQP_WRITE_EC); 149 149 sge_cmd = qpid << 8 | 3; 150 150 wqe->sge_cmd = cpu_to_be64(sge_cmd); ··· 548 548 V_EC_UP_TOKEN(T3_CTL_QP_TID) | F_EC_VALID)) << 32; 549 549 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); 550 550 memset(wqe, 0, sizeof(*wqe)); 551 - build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 1, 551 + build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0, 552 552 T3_CTL_QP_TID, 7); 553 553 wqe->flags = cpu_to_be32(MODQP_WRITE_EC); 554 554 sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; ··· 833 833 wqe->ird = cpu_to_be32(attr->ird); 834 834 wqe->qp_dma_addr = cpu_to_be64(attr->qp_dma_addr); 835 835 wqe->qp_dma_size = cpu_to_be32(attr->qp_dma_size); 836 - wqe->rsvd = 0; 836 + wqe->irs = cpu_to_be32(attr->irs); 837 837 skb->priority = 0; /* 0=>ToeQ; 1=>CtrlQ */ 838 838 return (cxgb3_ofld_send(rdev_p->t3cdev_p, skb)); 839 839 }
+2 -1
drivers/infiniband/hw/cxgb3/cxio_wr.h
··· 294 294 u64 qp_dma_addr; 295 295 u32 qp_dma_size; 296 296 u32 flags; 297 + u32 irs; 297 298 }; 298 299 299 300 struct t3_rdma_init_wr { ··· 315 314 __be32 ird; 316 315 __be64 qp_dma_addr; /* 7 */ 317 316 __be32 qp_dma_size; /* 8 */ 318 - u32 rsvd; 317 + u32 irs; 319 318 }; 320 319 321 320 struct t3_genbit {
+48 -60
drivers/infiniband/hw/cxgb3/iwch_cm.c
··· 254 254 cxgb3_remove_tid(ep->com.tdev, (void *)ep, ep->hwtid); 255 255 dst_release(ep->dst); 256 256 l2t_release(L2DATA(ep->com.tdev), ep->l2t); 257 - if (ep->com.tdev->type == T3B) 258 - release_tid(ep->com.tdev, ep->hwtid, NULL); 259 257 put_ep(&ep->com); 260 258 } 261 259 ··· 513 515 req->len = htonl(len); 514 516 req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | 515 517 V_TX_SNDBUF(snd_win>>15)); 516 - req->flags = htonl(F_TX_IMM_ACK|F_TX_INIT); 518 + req->flags = htonl(F_TX_INIT); 517 519 req->sndseq = htonl(ep->snd_seq); 518 520 BUG_ON(ep->mpa_skb); 519 521 ep->mpa_skb = skb; ··· 564 566 req->len = htonl(mpalen); 565 567 req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | 566 568 V_TX_SNDBUF(snd_win>>15)); 567 - req->flags = htonl(F_TX_IMM_ACK|F_TX_INIT); 569 + req->flags = htonl(F_TX_INIT); 568 570 req->sndseq = htonl(ep->snd_seq); 569 571 BUG_ON(ep->mpa_skb); 570 572 ep->mpa_skb = skb; ··· 616 618 req->len = htonl(len); 617 619 req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | 618 620 V_TX_SNDBUF(snd_win>>15)); 619 - req->flags = htonl(F_TX_MORE | F_TX_IMM_ACK | F_TX_INIT); 621 + req->flags = htonl(F_TX_INIT); 620 622 req->sndseq = htonl(ep->snd_seq); 621 623 ep->mpa_skb = skb; 622 624 state_set(&ep->com, MPA_REP_SENT); ··· 639 641 cxgb3_insert_tid(ep->com.tdev, &t3c_client, ep, tid); 640 642 641 643 ep->snd_seq = ntohl(req->snd_isn); 644 + ep->rcv_seq = ntohl(req->rcv_isn); 642 645 643 646 set_emss(ep, ntohs(req->tcp_opt)); 644 647 ··· 1022 1023 skb_pull(skb, sizeof(*hdr)); 1023 1024 skb_trim(skb, dlen); 1024 1025 1026 + ep->rcv_seq += dlen; 1027 + BUG_ON(ep->rcv_seq != (ntohl(hdr->seq) + dlen)); 1028 + 1025 1029 switch (state_read(&ep->com)) { 1026 1030 case MPA_REQ_SENT: 1027 1031 process_mpa_reply(ep, skb); ··· 1062 1060 struct iwch_ep *ep = ctx; 1063 1061 struct cpl_wr_ack *hdr = cplhdr(skb); 1064 1062 unsigned int credits = ntohs(hdr->credits); 1065 - enum iwch_qp_attr_mask mask; 1066 1063 1067 1064 PDBG("%s ep %p credits %u\n", __FUNCTION__, ep, credits); 1068 1065 ··· 1073 1072 ep->mpa_skb = NULL; 1074 1073 dst_confirm(ep->dst); 1075 1074 if (state_read(&ep->com) == MPA_REP_SENT) { 1076 - struct iwch_qp_attributes attrs; 1077 - 1078 - /* bind QP to EP and move to RTS */ 1079 - attrs.mpa_attr = ep->mpa_attr; 1080 - attrs.max_ird = ep->ord; 1081 - attrs.max_ord = ep->ord; 1082 - attrs.llp_stream_handle = ep; 1083 - attrs.next_state = IWCH_QP_STATE_RTS; 1084 - 1085 - /* bind QP and TID with INIT_WR */ 1086 - mask = IWCH_QP_ATTR_NEXT_STATE | 1087 - IWCH_QP_ATTR_LLP_STREAM_HANDLE | 1088 - IWCH_QP_ATTR_MPA_ATTR | 1089 - IWCH_QP_ATTR_MAX_IRD | 1090 - IWCH_QP_ATTR_MAX_ORD; 1091 - 1092 - ep->com.rpl_err = iwch_modify_qp(ep->com.qp->rhp, 1093 - ep->com.qp, mask, &attrs, 1); 1094 - 1095 - if (!ep->com.rpl_err) { 1096 - state_set(&ep->com, FPDU_MODE); 1097 - established_upcall(ep); 1098 - } 1099 - 1100 1075 ep->com.rpl_done = 1; 1101 1076 PDBG("waking up ep %p\n", ep); 1102 1077 wake_up(&ep->com.waitq); ··· 1101 1124 return CPL_RET_BUF_DONE; 1102 1125 } 1103 1126 1127 + /* 1128 + * Return whether a failed active open has allocated a TID 1129 + */ 1130 + static inline int act_open_has_tid(int status) 1131 + { 1132 + return status != CPL_ERR_TCAM_FULL && status != CPL_ERR_CONN_EXIST && 1133 + status != CPL_ERR_ARP_MISS; 1134 + } 1135 + 1104 1136 static int act_open_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) 1105 1137 { 1106 1138 struct iwch_ep *ep = ctx; ··· 1119 1133 status2errno(rpl->status)); 1120 1134 connect_reply_upcall(ep, status2errno(rpl->status)); 1121 1135 state_set(&ep->com, DEAD); 1122 - if (ep->com.tdev->type == T3B) 1136 + if (ep->com.tdev->type == T3B && act_open_has_tid(rpl->status)) 1123 1137 release_tid(ep->com.tdev, GET_TID(rpl), NULL); 1124 1138 cxgb3_free_atid(ep->com.tdev, ep->atid); 1125 1139 dst_release(ep->dst); ··· 1364 1378 1365 1379 PDBG("%s ep %p\n", __FUNCTION__, ep); 1366 1380 ep->snd_seq = ntohl(req->snd_isn); 1381 + ep->rcv_seq = ntohl(req->rcv_isn); 1367 1382 1368 1383 set_emss(ep, ntohs(req->tcp_opt)); 1369 1384 ··· 1472 1485 int ret; 1473 1486 int state; 1474 1487 1488 + if (is_neg_adv_abort(req->status)) { 1489 + PDBG("%s neg_adv_abort ep %p tid %d\n", __FUNCTION__, ep, 1490 + ep->hwtid); 1491 + t3_l2t_send_event(ep->com.tdev, ep->l2t); 1492 + return CPL_RET_BUF_DONE; 1493 + } 1494 + 1475 1495 /* 1476 1496 * We get 2 peer aborts from the HW. The first one must 1477 1497 * be ignored except for scribbling that we need one more. 1478 1498 */ 1479 1499 if (!(ep->flags & PEER_ABORT_IN_PROGRESS)) { 1480 1500 ep->flags |= PEER_ABORT_IN_PROGRESS; 1481 - return CPL_RET_BUF_DONE; 1482 - } 1483 - 1484 - if (is_neg_adv_abort(req->status)) { 1485 - PDBG("%s neg_adv_abort ep %p tid %d\n", __FUNCTION__, ep, 1486 - ep->hwtid); 1487 - t3_l2t_send_event(ep->com.tdev, ep->l2t); 1488 1501 return CPL_RET_BUF_DONE; 1489 1502 } 1490 1503 ··· 1719 1732 struct iwch_qp *qp = get_qhp(h, conn_param->qpn); 1720 1733 1721 1734 PDBG("%s ep %p tid %u\n", __FUNCTION__, ep, ep->hwtid); 1722 - if (state_read(&ep->com) == DEAD) { 1723 - put_ep(&ep->com); 1735 + if (state_read(&ep->com) == DEAD) 1724 1736 return -ECONNRESET; 1725 - } 1726 1737 1727 1738 BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD); 1728 1739 BUG_ON(!qp); ··· 1740 1755 ep->ird = conn_param->ird; 1741 1756 ep->ord = conn_param->ord; 1742 1757 PDBG("%s %d ird %d ord %d\n", __FUNCTION__, __LINE__, ep->ird, ep->ord); 1758 + 1743 1759 get_ep(&ep->com); 1744 - err = send_mpa_reply(ep, conn_param->private_data, 1745 - conn_param->private_data_len); 1746 - if (err) { 1747 - ep->com.cm_id = NULL; 1748 - ep->com.qp = NULL; 1749 - cm_id->rem_ref(cm_id); 1750 - abort_connection(ep, NULL, GFP_KERNEL); 1751 - put_ep(&ep->com); 1752 - return err; 1753 - } 1754 1760 1755 1761 /* bind QP to EP and move to RTS */ 1756 1762 attrs.mpa_attr = ep->mpa_attr; ··· 1759 1783 1760 1784 err = iwch_modify_qp(ep->com.qp->rhp, 1761 1785 ep->com.qp, mask, &attrs, 1); 1786 + if (err) 1787 + goto err; 1762 1788 1763 - if (err) { 1764 - ep->com.cm_id = NULL; 1765 - ep->com.qp = NULL; 1766 - cm_id->rem_ref(cm_id); 1767 - abort_connection(ep, NULL, GFP_KERNEL); 1768 - } else { 1769 - state_set(&ep->com, FPDU_MODE); 1770 - established_upcall(ep); 1771 - } 1789 + err = send_mpa_reply(ep, conn_param->private_data, 1790 + conn_param->private_data_len); 1791 + if (err) 1792 + goto err; 1793 + 1794 + /* wait for wr_ack */ 1795 + wait_event(ep->com.waitq, ep->com.rpl_done); 1796 + err = ep->com.rpl_err; 1797 + if (err) 1798 + goto err; 1799 + 1800 + state_set(&ep->com, FPDU_MODE); 1801 + established_upcall(ep); 1802 + put_ep(&ep->com); 1803 + return 0; 1804 + err: 1805 + ep->com.cm_id = NULL; 1806 + ep->com.qp = NULL; 1807 + cm_id->rem_ref(cm_id); 1772 1808 put_ep(&ep->com); 1773 1809 return err; 1774 1810 }
+1
drivers/infiniband/hw/cxgb3/iwch_cm.h
··· 175 175 unsigned int atid; 176 176 u32 hwtid; 177 177 u32 snd_seq; 178 + u32 rcv_seq; 178 179 struct l2t_entry *l2t; 179 180 struct dst_entry *dst; 180 181 struct sk_buff *mpa_skb;
+4 -3
drivers/infiniband/hw/cxgb3/iwch_provider.c
··· 1163 1163 dev->ibdev.post_recv = iwch_post_receive; 1164 1164 1165 1165 1166 - dev->ibdev.iwcm = 1167 - (struct iw_cm_verbs *) kmalloc(sizeof(struct iw_cm_verbs), 1168 - GFP_KERNEL); 1166 + dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); 1167 + if (!dev->ibdev.iwcm) 1168 + return -ENOMEM; 1169 + 1169 1170 dev->ibdev.iwcm->connect = iwch_connect; 1170 1171 dev->ibdev.iwcm->accept = iwch_accept_cr; 1171 1172 dev->ibdev.iwcm->reject = iwch_reject_cr;
+4 -3
drivers/infiniband/hw/cxgb3/iwch_qp.c
··· 628 628 /* immediate data starts here. */ 629 629 term = (struct terminate_message *)wqe->send.sgl; 630 630 build_term_codes(rsp_msg, &term->layer_etype, &term->ecode); 631 - build_fw_riwrh((void *)wqe, T3_WR_SEND, 632 - T3_COMPLETION_FLAG | T3_NOTIFY_FLAG, 1, 633 - qhp->ep->hwtid, 5); 631 + wqe->send.wrh.op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(T3_WR_SEND) | 632 + V_FW_RIWR_FLAGS(T3_COMPLETION_FLAG | T3_NOTIFY_FLAG)); 633 + wqe->send.wrh.gen_tid_len = cpu_to_be32(V_FW_RIWR_TID(qhp->ep->hwtid)); 634 634 skb->priority = CPL_PRIORITY_DATA; 635 635 return cxgb3_ofld_send(qhp->rhp->rdev.t3cdev_p, skb); 636 636 } ··· 732 732 init_attr.qp_dma_addr = qhp->wq.dma_addr; 733 733 init_attr.qp_dma_size = (1UL << qhp->wq.size_log2); 734 734 init_attr.flags = rqes_posted(qhp) ? RECVS_POSTED : 0; 735 + init_attr.irs = qhp->ep->rcv_seq; 735 736 PDBG("%s init_attr.rq_addr 0x%x init_attr.rq_size = %d " 736 737 "flags 0x%x qpcaps 0x%x\n", __FUNCTION__, 737 738 init_attr.rq_addr, init_attr.rq_size,
+1 -1
drivers/infiniband/hw/ehca/Kconfig
··· 1 1 config INFINIBAND_EHCA 2 2 tristate "eHCA support" 3 - depends on IBMEBUS && INFINIBAND 3 + depends on IBMEBUS 4 4 ---help--- 5 5 This driver supports the IBM pSeries eHCA InfiniBand adapter. 6 6
+4 -2
drivers/infiniband/hw/ehca/ehca_av.c
··· 118 118 } 119 119 memcpy(&av->av.grh.word_1, &gid, sizeof(gid)); 120 120 } 121 - av->av.pmtu = EHCA_MAX_MTU; 121 + av->av.pmtu = shca->max_mtu; 122 122 123 123 /* dgid comes in grh.word_3 */ 124 124 memcpy(&av->av.grh.word_3, &ah_attr->grh.dgid, ··· 137 137 struct ehca_av *av; 138 138 struct ehca_ud_av new_ehca_av; 139 139 struct ehca_pd *my_pd = container_of(ah->pd, struct ehca_pd, ib_pd); 140 + struct ehca_shca *shca = container_of(ah->pd->device, struct ehca_shca, 141 + ib_device); 140 142 u32 cur_pid = current->tgid; 141 143 142 144 if (my_pd->ib_pd.uobject && my_pd->ib_pd.uobject->context && ··· 194 192 memcpy(&new_ehca_av.grh.word_1, &gid, sizeof(gid)); 195 193 } 196 194 197 - new_ehca_av.pmtu = EHCA_MAX_MTU; 195 + new_ehca_av.pmtu = shca->max_mtu; 198 196 199 197 memcpy(&new_ehca_av.grh.word_3, &ah_attr->grh.dgid, 200 198 sizeof(ah_attr->grh.dgid));
+62 -13
drivers/infiniband/hw/ehca/ehca_classes.h
··· 5 5 * 6 6 * Authors: Heiko J Schick <schickhj@de.ibm.com> 7 7 * Christoph Raisch <raisch@de.ibm.com> 8 + * Joachim Fenkes <fenkes@de.ibm.com> 8 9 * 9 10 * Copyright (c) 2005 IBM Corporation 10 11 * ··· 87 86 struct ehca_eqe_cache_entry eqe_cache[EHCA_EQE_CACHE_SIZE]; 88 87 }; 89 88 89 + struct ehca_sma_attr { 90 + u16 lid, lmc, sm_sl, sm_lid; 91 + u16 pkey_tbl_len, pkeys[16]; 92 + }; 93 + 90 94 struct ehca_sport { 91 95 struct ib_cq *ibcq_aqp1; 92 96 struct ib_qp *ibqp_aqp1; 93 97 enum ib_rate rate; 94 98 enum ib_port_state port_state; 99 + struct ehca_sma_attr saved_attr; 95 100 }; 96 101 97 102 struct ehca_shca { ··· 114 107 struct ehca_pd *pd; 115 108 struct h_galpas galpas; 116 109 struct mutex modify_mutex; 110 + u64 hca_cap; 111 + int max_mtu; 117 112 }; 118 113 119 114 struct ehca_pd { ··· 124 115 u32 ownpid; 125 116 }; 126 117 118 + enum ehca_ext_qp_type { 119 + EQPT_NORMAL = 0, 120 + EQPT_LLQP = 1, 121 + EQPT_SRQBASE = 2, 122 + EQPT_SRQ = 3, 123 + }; 124 + 127 125 struct ehca_qp { 128 - struct ib_qp ib_qp; 126 + union { 127 + struct ib_qp ib_qp; 128 + struct ib_srq ib_srq; 129 + }; 129 130 u32 qp_type; 131 + enum ehca_ext_qp_type ext_type; 130 132 struct ipz_queue ipz_squeue; 131 133 struct ipz_queue ipz_rqueue; 132 134 struct h_galpas galpas; ··· 160 140 u32 mm_count_galpa; 161 141 }; 162 142 143 + #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ) 144 + #define HAS_SQ(qp) (qp->ext_type != EQPT_SRQ) 145 + #define HAS_RQ(qp) (qp->ext_type != EQPT_SRQBASE) 146 + 163 147 /* must be power of 2 */ 164 148 #define QP_HASHTAB_LEN 8 165 149 ··· 180 156 spinlock_t cb_lock; 181 157 struct hlist_head qp_hashtab[QP_HASHTAB_LEN]; 182 158 struct list_head entry; 183 - u32 nr_callbacks; /* #events assigned to cpu by scaling code */ 184 - u32 nr_events; /* #events seen */ 159 + u32 nr_callbacks; /* #events assigned to cpu by scaling code */ 160 + atomic_t nr_events; /* #events seen */ 185 161 wait_queue_head_t wait_completion; 186 162 spinlock_t task_lock; 187 163 u32 ownpid; ··· 299 275 int ehca_init_mrmw_cache(void); 300 276 void ehca_cleanup_mrmw_cache(void); 301 277 302 - extern spinlock_t ehca_qp_idr_lock; 303 - extern spinlock_t ehca_cq_idr_lock; 304 - extern spinlock_t hcall_lock; 278 + extern rwlock_t ehca_qp_idr_lock; 279 + extern rwlock_t ehca_cq_idr_lock; 305 280 extern struct idr ehca_qp_idr; 306 281 extern struct idr ehca_cq_idr; 307 282 ··· 328 305 u32 qp_num; 329 306 u32 token; 330 307 u32 qp_type; 308 + u32 ext_type; 331 309 u32 qkey; 332 310 /* qp_num assigned by ehca: sqp0/1 may have got different numbers */ 333 311 u32 real_qp_num; ··· 344 320 struct ipz_eq_handle eq_handle; 345 321 }; 346 322 323 + enum ehca_service_type { 324 + ST_RC = 0, 325 + ST_UC = 1, 326 + ST_RD = 2, 327 + ST_UD = 3, 328 + }; 329 + 330 + enum ehca_ll_comp_flags { 331 + LLQP_SEND_COMP = 0x20, 332 + LLQP_RECV_COMP = 0x40, 333 + LLQP_COMP_MASK = 0x60, 334 + }; 335 + 347 336 struct ehca_alloc_qp_parms { 348 - int servicetype; 337 + /* input parameters */ 338 + enum ehca_service_type servicetype; 349 339 int sigtype; 350 - int daqp_ctrl; 351 - int max_send_sge; 352 - int max_recv_sge; 340 + enum ehca_ext_qp_type ext_type; 341 + enum ehca_ll_comp_flags ll_comp_flags; 342 + 343 + int max_send_wr, max_recv_wr; 344 + int max_send_sge, max_recv_sge; 353 345 int ud_av_l_key_ctl; 346 + 347 + u32 token; 348 + struct ipz_eq_handle eq_handle; 349 + struct ipz_pd pd; 350 + struct ipz_cq_handle send_cq_handle, recv_cq_handle; 351 + 352 + u32 srq_qpn, srq_token, srq_limit; 353 + 354 + /* output parameters */ 355 + u32 real_qp_num; 356 + struct ipz_qp_handle qp_handle; 357 + struct h_galpas galpas; 354 358 355 359 u16 act_nr_send_wqes; 356 360 u16 act_nr_recv_wqes; ··· 387 335 388 336 u32 nr_rq_pages; 389 337 u32 nr_sq_pages; 390 - 391 - struct ipz_eq_handle ipz_eq_handle; 392 - struct ipz_pd pd; 393 338 }; 394 339 395 340 int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp);
+2 -2
drivers/infiniband/hw/ehca/ehca_classes_pSeries.h
··· 228 228 #define MQPCB_QP_NUMBER EHCA_BMASK_IBM(8,31) 229 229 #define MQPCB_MASK_QP_ENABLE EHCA_BMASK_IBM(48,48) 230 230 #define MQPCB_QP_ENABLE EHCA_BMASK_IBM(31,31) 231 - #define MQPCB_MASK_CURR_SQR_LIMIT EHCA_BMASK_IBM(49,49) 232 - #define MQPCB_CURR_SQR_LIMIT EHCA_BMASK_IBM(15,31) 231 + #define MQPCB_MASK_CURR_SRQ_LIMIT EHCA_BMASK_IBM(49,49) 232 + #define MQPCB_CURR_SRQ_LIMIT EHCA_BMASK_IBM(16,31) 233 233 #define MQPCB_MASK_QP_AFF_ASYN_EV_LOG_REG EHCA_BMASK_IBM(50,50) 234 234 #define MQPCB_MASK_SHARED_RQ_HNDL EHCA_BMASK_IBM(51,51) 235 235
+21 -29
drivers/infiniband/hw/ehca/ehca_cq.c
··· 56 56 { 57 57 unsigned int qp_num = qp->real_qp_num; 58 58 unsigned int key = qp_num & (QP_HASHTAB_LEN-1); 59 - unsigned long spl_flags; 59 + unsigned long flags; 60 60 61 - spin_lock_irqsave(&cq->spinlock, spl_flags); 61 + spin_lock_irqsave(&cq->spinlock, flags); 62 62 hlist_add_head(&qp->list_entries, &cq->qp_hashtab[key]); 63 - spin_unlock_irqrestore(&cq->spinlock, spl_flags); 63 + spin_unlock_irqrestore(&cq->spinlock, flags); 64 64 65 65 ehca_dbg(cq->ib_cq.device, "cq_num=%x real_qp_num=%x", 66 66 cq->cq_number, qp_num); ··· 74 74 unsigned int key = real_qp_num & (QP_HASHTAB_LEN-1); 75 75 struct hlist_node *iter; 76 76 struct ehca_qp *qp; 77 - unsigned long spl_flags; 77 + unsigned long flags; 78 78 79 - spin_lock_irqsave(&cq->spinlock, spl_flags); 79 + spin_lock_irqsave(&cq->spinlock, flags); 80 80 hlist_for_each(iter, &cq->qp_hashtab[key]) { 81 81 qp = hlist_entry(iter, struct ehca_qp, list_entries); 82 82 if (qp->real_qp_num == real_qp_num) { ··· 88 88 break; 89 89 } 90 90 } 91 - spin_unlock_irqrestore(&cq->spinlock, spl_flags); 91 + spin_unlock_irqrestore(&cq->spinlock, flags); 92 92 if (ret) 93 93 ehca_err(cq->ib_cq.device, 94 94 "qp not found cq_num=%x real_qp_num=%x", ··· 146 146 spin_lock_init(&my_cq->spinlock); 147 147 spin_lock_init(&my_cq->cb_lock); 148 148 spin_lock_init(&my_cq->task_lock); 149 + atomic_set(&my_cq->nr_events, 0); 149 150 init_waitqueue_head(&my_cq->wait_completion); 150 151 my_cq->ownpid = current->tgid; 151 152 ··· 163 162 goto create_cq_exit1; 164 163 } 165 164 166 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 165 + write_lock_irqsave(&ehca_cq_idr_lock, flags); 167 166 ret = idr_get_new(&ehca_cq_idr, my_cq, &my_cq->token); 168 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 167 + write_unlock_irqrestore(&ehca_cq_idr_lock, flags); 169 168 170 169 } while (ret == -EAGAIN); 171 170 ··· 294 293 "cq_num=%x h_ret=%lx", my_cq, my_cq->cq_number, h_ret); 295 294 296 295 create_cq_exit2: 297 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 296 + write_lock_irqsave(&ehca_cq_idr_lock, flags); 298 297 idr_remove(&ehca_cq_idr, my_cq->token); 299 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 298 + write_unlock_irqrestore(&ehca_cq_idr_lock, flags); 300 299 301 300 create_cq_exit1: 302 301 kmem_cache_free(cq_cache, my_cq); 303 302 304 303 return cq; 305 - } 306 - 307 - static int get_cq_nr_events(struct ehca_cq *my_cq) 308 - { 309 - int ret; 310 - unsigned long flags; 311 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 312 - ret = my_cq->nr_events; 313 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 314 - return ret; 315 304 } 316 305 317 306 int ehca_destroy_cq(struct ib_cq *cq) ··· 330 339 } 331 340 } 332 341 333 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 334 - while (my_cq->nr_events) { 335 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 336 - wait_event(my_cq->wait_completion, !get_cq_nr_events(my_cq)); 337 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 338 - /* recheck nr_events to assure no cqe has just arrived */ 339 - } 340 - 342 + /* 343 + * remove the CQ from the idr first to make sure 344 + * no more interrupt tasklets will touch this CQ 345 + */ 346 + write_lock_irqsave(&ehca_cq_idr_lock, flags); 341 347 idr_remove(&ehca_cq_idr, my_cq->token); 342 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 348 + write_unlock_irqrestore(&ehca_cq_idr_lock, flags); 343 349 350 + /* now wait until all pending events have completed */ 351 + wait_event(my_cq->wait_completion, !atomic_read(&my_cq->nr_events)); 352 + 353 + /* nobody's using our CQ any longer -- we can destroy it */ 344 354 h_ret = hipz_h_destroy_cq(adapter_handle, my_cq, 0); 345 355 if (h_ret == H_R_STATE) { 346 356 /* cq in err: read err data and destroy it forcibly */
+58 -3
drivers/infiniband/hw/ehca/ehca_hca.c
··· 45 45 46 46 int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) 47 47 { 48 - int ret = 0; 48 + int i, ret = 0; 49 49 struct ehca_shca *shca = container_of(ibdev, struct ehca_shca, 50 50 ib_device); 51 51 struct hipz_query_hca *rblock; 52 + 53 + static const u32 cap_mapping[] = { 54 + IB_DEVICE_RESIZE_MAX_WR, HCA_CAP_WQE_RESIZE, 55 + IB_DEVICE_BAD_PKEY_CNTR, HCA_CAP_BAD_P_KEY_CTR, 56 + IB_DEVICE_BAD_QKEY_CNTR, HCA_CAP_Q_KEY_VIOL_CTR, 57 + IB_DEVICE_RAW_MULTI, HCA_CAP_RAW_PACKET_MCAST, 58 + IB_DEVICE_AUTO_PATH_MIG, HCA_CAP_AUTO_PATH_MIG, 59 + IB_DEVICE_CHANGE_PHY_PORT, HCA_CAP_SQD_RTS_PORT_CHANGE, 60 + IB_DEVICE_UD_AV_PORT_ENFORCE, HCA_CAP_AH_PORT_NR_CHECK, 61 + IB_DEVICE_CURR_QP_STATE_MOD, HCA_CAP_CUR_QP_STATE_MOD, 62 + IB_DEVICE_SHUTDOWN_PORT, HCA_CAP_SHUTDOWN_PORT, 63 + IB_DEVICE_INIT_TYPE, HCA_CAP_INIT_TYPE, 64 + IB_DEVICE_PORT_ACTIVE_EVENT, HCA_CAP_PORT_ACTIVE_EVENT, 65 + }; 52 66 53 67 rblock = ehca_alloc_fw_ctrlblock(GFP_KERNEL); 54 68 if (!rblock) { ··· 109 95 = min_t(int, rblock->max_mcast_qp_attach, INT_MAX); 110 96 props->max_total_mcast_qp_attach 111 97 = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX); 98 + 99 + /* translate device capabilities */ 100 + props->device_cap_flags = IB_DEVICE_SYS_IMAGE_GUID | 101 + IB_DEVICE_RC_RNR_NAK_GEN | IB_DEVICE_N_NOTIFY_CQ; 102 + for (i = 0; i < ARRAY_SIZE(cap_mapping); i += 2) 103 + if (rblock->hca_cap_indicators & cap_mapping[i + 1]) 104 + props->device_cap_flags |= cap_mapping[i]; 112 105 113 106 query_device1: 114 107 ehca_free_fw_ctrlblock(rblock); ··· 188 167 props->phys_state = 0x5; 189 168 190 169 query_port1: 170 + ehca_free_fw_ctrlblock(rblock); 171 + 172 + return ret; 173 + } 174 + 175 + int ehca_query_sma_attr(struct ehca_shca *shca, 176 + u8 port, struct ehca_sma_attr *attr) 177 + { 178 + int ret = 0; 179 + struct hipz_query_port *rblock; 180 + 181 + rblock = ehca_alloc_fw_ctrlblock(GFP_ATOMIC); 182 + if (!rblock) { 183 + ehca_err(&shca->ib_device, "Can't allocate rblock memory."); 184 + return -ENOMEM; 185 + } 186 + 187 + if (hipz_h_query_port(shca->ipz_hca_handle, port, rblock) != H_SUCCESS) { 188 + ehca_err(&shca->ib_device, "Can't query port properties"); 189 + ret = -EINVAL; 190 + goto query_sma_attr1; 191 + } 192 + 193 + memset(attr, 0, sizeof(struct ehca_sma_attr)); 194 + 195 + attr->lid = rblock->lid; 196 + attr->lmc = rblock->lmc; 197 + attr->sm_sl = rblock->sm_sl; 198 + attr->sm_lid = rblock->sm_lid; 199 + 200 + attr->pkey_tbl_len = rblock->pkey_tbl_len; 201 + memcpy(attr->pkeys, rblock->pkey_entries, sizeof(attr->pkeys)); 202 + 203 + query_sma_attr1: 191 204 ehca_free_fw_ctrlblock(rblock); 192 205 193 206 return ret; ··· 316 261 } 317 262 318 263 if (mutex_lock_interruptible(&shca->modify_mutex)) 319 - return -ERESTARTSYS; 264 + return -ERESTARTSYS; 320 265 321 266 rblock = ehca_alloc_fw_ctrlblock(GFP_KERNEL); 322 267 if (!rblock) { ··· 345 290 ehca_free_fw_ctrlblock(rblock); 346 291 347 292 modify_port1: 348 - mutex_unlock(&shca->modify_mutex); 293 + mutex_unlock(&shca->modify_mutex); 349 294 350 295 return ret; 351 296 }
+79 -57
drivers/infiniband/hw/ehca/ehca_irq.c
··· 5 5 * 6 6 * Authors: Heiko J Schick <schickhj@de.ibm.com> 7 7 * Khadija Souissi <souissi@de.ibm.com> 8 + * Hoang-Nam Nguyen <hnguyen@de.ibm.com> 9 + * Joachim Fenkes <fenkes@de.ibm.com> 8 10 * 9 11 * Copyright (c) 2005 IBM Corporation 10 12 * ··· 61 59 #define NEQE_EVENT_CODE EHCA_BMASK_IBM(2,7) 62 60 #define NEQE_PORT_NUMBER EHCA_BMASK_IBM(8,15) 63 61 #define NEQE_PORT_AVAILABILITY EHCA_BMASK_IBM(16,16) 62 + #define NEQE_DISRUPTIVE EHCA_BMASK_IBM(16,16) 64 63 65 64 #define ERROR_DATA_LENGTH EHCA_BMASK_IBM(52,63) 66 65 #define ERROR_DATA_TYPE EHCA_BMASK_IBM(0,7) ··· 181 178 { 182 179 struct ib_event event; 183 180 struct ehca_qp *qp; 184 - unsigned long flags; 185 181 u32 token = EHCA_BMASK_GET(EQE_QP_TOKEN, eqe); 186 182 187 - spin_lock_irqsave(&ehca_qp_idr_lock, flags); 183 + read_lock(&ehca_qp_idr_lock); 188 184 qp = idr_find(&ehca_qp_idr, token); 189 - spin_unlock_irqrestore(&ehca_qp_idr_lock, flags); 185 + read_unlock(&ehca_qp_idr_lock); 190 186 191 187 192 188 if (!qp) ··· 209 207 u64 eqe) 210 208 { 211 209 struct ehca_cq *cq; 212 - unsigned long flags; 213 210 u32 token = EHCA_BMASK_GET(EQE_CQ_TOKEN, eqe); 214 211 215 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 212 + read_lock(&ehca_cq_idr_lock); 216 213 cq = idr_find(&ehca_cq_idr, token); 217 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 214 + if (cq) 215 + atomic_inc(&cq->nr_events); 216 + read_unlock(&ehca_cq_idr_lock); 218 217 219 218 if (!cq) 220 219 return; 221 220 222 221 ehca_error_data(shca, cq, cq->ipz_cq_handle.handle); 222 + 223 + if (atomic_dec_and_test(&cq->nr_events)) 224 + wake_up(&cq->wait_completion); 223 225 224 226 return; 225 227 } ··· 287 281 return; 288 282 } 289 283 290 - static void parse_ec(struct ehca_shca *shca, u64 eqe) 284 + static void dispatch_port_event(struct ehca_shca *shca, int port_num, 285 + enum ib_event_type type, const char *msg) 291 286 { 292 287 struct ib_event event; 288 + 289 + ehca_info(&shca->ib_device, "port %d %s.", port_num, msg); 290 + event.device = &shca->ib_device; 291 + event.event = type; 292 + event.element.port_num = port_num; 293 + ib_dispatch_event(&event); 294 + } 295 + 296 + static void notify_port_conf_change(struct ehca_shca *shca, int port_num) 297 + { 298 + struct ehca_sma_attr new_attr; 299 + struct ehca_sma_attr *old_attr = &shca->sport[port_num - 1].saved_attr; 300 + 301 + ehca_query_sma_attr(shca, port_num, &new_attr); 302 + 303 + if (new_attr.sm_sl != old_attr->sm_sl || 304 + new_attr.sm_lid != old_attr->sm_lid) 305 + dispatch_port_event(shca, port_num, IB_EVENT_SM_CHANGE, 306 + "SM changed"); 307 + 308 + if (new_attr.lid != old_attr->lid || 309 + new_attr.lmc != old_attr->lmc) 310 + dispatch_port_event(shca, port_num, IB_EVENT_LID_CHANGE, 311 + "LID changed"); 312 + 313 + if (new_attr.pkey_tbl_len != old_attr->pkey_tbl_len || 314 + memcmp(new_attr.pkeys, old_attr->pkeys, 315 + sizeof(u16) * new_attr.pkey_tbl_len)) 316 + dispatch_port_event(shca, port_num, IB_EVENT_PKEY_CHANGE, 317 + "P_Key changed"); 318 + 319 + *old_attr = new_attr; 320 + } 321 + 322 + static void parse_ec(struct ehca_shca *shca, u64 eqe) 323 + { 293 324 u8 ec = EHCA_BMASK_GET(NEQE_EVENT_CODE, eqe); 294 325 u8 port = EHCA_BMASK_GET(NEQE_PORT_NUMBER, eqe); 295 326 296 327 switch (ec) { 297 328 case 0x30: /* port availability change */ 298 329 if (EHCA_BMASK_GET(NEQE_PORT_AVAILABILITY, eqe)) { 299 - ehca_info(&shca->ib_device, 300 - "port %x is active.", port); 301 - event.device = &shca->ib_device; 302 - event.event = IB_EVENT_PORT_ACTIVE; 303 - event.element.port_num = port; 304 330 shca->sport[port - 1].port_state = IB_PORT_ACTIVE; 305 - ib_dispatch_event(&event); 331 + dispatch_port_event(shca, port, IB_EVENT_PORT_ACTIVE, 332 + "is active"); 333 + ehca_query_sma_attr(shca, port, 334 + &shca->sport[port - 1].saved_attr); 306 335 } else { 307 - ehca_info(&shca->ib_device, 308 - "port %x is inactive.", port); 309 - event.device = &shca->ib_device; 310 - event.event = IB_EVENT_PORT_ERR; 311 - event.element.port_num = port; 312 336 shca->sport[port - 1].port_state = IB_PORT_DOWN; 313 - ib_dispatch_event(&event); 337 + dispatch_port_event(shca, port, IB_EVENT_PORT_ERR, 338 + "is inactive"); 314 339 } 315 340 break; 316 341 case 0x31: ··· 349 312 * disruptive change is caused by 350 313 * LID, PKEY or SM change 351 314 */ 352 - ehca_warn(&shca->ib_device, 353 - "disruptive port %x configuration change", port); 315 + if (EHCA_BMASK_GET(NEQE_DISRUPTIVE, eqe)) { 316 + ehca_warn(&shca->ib_device, "disruptive port " 317 + "%d configuration change", port); 354 318 355 - ehca_info(&shca->ib_device, 356 - "port %x is inactive.", port); 357 - event.device = &shca->ib_device; 358 - event.event = IB_EVENT_PORT_ERR; 359 - event.element.port_num = port; 360 - shca->sport[port - 1].port_state = IB_PORT_DOWN; 361 - ib_dispatch_event(&event); 319 + shca->sport[port - 1].port_state = IB_PORT_DOWN; 320 + dispatch_port_event(shca, port, IB_EVENT_PORT_ERR, 321 + "is inactive"); 362 322 363 - ehca_info(&shca->ib_device, 364 - "port %x is active.", port); 365 - event.device = &shca->ib_device; 366 - event.event = IB_EVENT_PORT_ACTIVE; 367 - event.element.port_num = port; 368 - shca->sport[port - 1].port_state = IB_PORT_ACTIVE; 369 - ib_dispatch_event(&event); 323 + shca->sport[port - 1].port_state = IB_PORT_ACTIVE; 324 + dispatch_port_event(shca, port, IB_EVENT_PORT_ACTIVE, 325 + "is active"); 326 + } else 327 + notify_port_conf_change(shca, port); 370 328 break; 371 329 case 0x32: /* adapter malfunction */ 372 330 ehca_err(&shca->ib_device, "Adapter malfunction."); ··· 436 404 { 437 405 u64 eqe_value; 438 406 u32 token; 439 - unsigned long flags; 440 407 struct ehca_cq *cq; 441 408 442 409 eqe_value = eqe->entry; ··· 443 412 if (EHCA_BMASK_GET(EQE_COMPLETION_EVENT, eqe_value)) { 444 413 ehca_dbg(&shca->ib_device, "Got completion event"); 445 414 token = EHCA_BMASK_GET(EQE_CQ_TOKEN, eqe_value); 446 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 415 + read_lock(&ehca_cq_idr_lock); 447 416 cq = idr_find(&ehca_cq_idr, token); 417 + if (cq) 418 + atomic_inc(&cq->nr_events); 419 + read_unlock(&ehca_cq_idr_lock); 448 420 if (cq == NULL) { 449 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 450 421 ehca_err(&shca->ib_device, 451 422 "Invalid eqe for non-existing cq token=%x", 452 423 token); 453 424 return; 454 425 } 455 426 reset_eq_pending(cq); 456 - cq->nr_events++; 457 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 458 427 if (ehca_scaling_code) 459 428 queue_comp_task(cq); 460 429 else { 461 430 comp_event_callback(cq); 462 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 463 - cq->nr_events--; 464 - if (!cq->nr_events) 431 + if (atomic_dec_and_test(&cq->nr_events)) 465 432 wake_up(&cq->wait_completion); 466 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 467 433 } 468 434 } else { 469 435 ehca_dbg(&shca->ib_device, "Got non completion event"); ··· 504 476 eqe_value = eqe_cache[eqe_cnt].eqe->entry; 505 477 if (EHCA_BMASK_GET(EQE_COMPLETION_EVENT, eqe_value)) { 506 478 token = EHCA_BMASK_GET(EQE_CQ_TOKEN, eqe_value); 507 - spin_lock(&ehca_cq_idr_lock); 479 + read_lock(&ehca_cq_idr_lock); 508 480 eqe_cache[eqe_cnt].cq = idr_find(&ehca_cq_idr, token); 481 + if (eqe_cache[eqe_cnt].cq) 482 + atomic_inc(&eqe_cache[eqe_cnt].cq->nr_events); 483 + read_unlock(&ehca_cq_idr_lock); 509 484 if (!eqe_cache[eqe_cnt].cq) { 510 - spin_unlock(&ehca_cq_idr_lock); 511 485 ehca_err(&shca->ib_device, 512 486 "Invalid eqe for non-existing cq " 513 487 "token=%x", token); 514 488 continue; 515 489 } 516 - eqe_cache[eqe_cnt].cq->nr_events++; 517 - spin_unlock(&ehca_cq_idr_lock); 518 490 } else 519 491 eqe_cache[eqe_cnt].cq = NULL; 520 492 eqe_cnt++; ··· 545 517 else { 546 518 struct ehca_cq *cq = eq->eqe_cache[i].cq; 547 519 comp_event_callback(cq); 548 - spin_lock(&ehca_cq_idr_lock); 549 - cq->nr_events--; 550 - if (!cq->nr_events) 520 + if (atomic_dec_and_test(&cq->nr_events)) 551 521 wake_up(&cq->wait_completion); 552 - spin_unlock(&ehca_cq_idr_lock); 553 522 } 554 523 } else { 555 524 ehca_dbg(&shca->ib_device, "Got non completion event"); ··· 646 621 while (!list_empty(&cct->cq_list)) { 647 622 cq = list_entry(cct->cq_list.next, struct ehca_cq, entry); 648 623 spin_unlock_irqrestore(&cct->task_lock, flags); 649 - comp_event_callback(cq); 650 624 651 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 652 - cq->nr_events--; 653 - if (!cq->nr_events) 625 + comp_event_callback(cq); 626 + if (atomic_dec_and_test(&cq->nr_events)) 654 627 wake_up(&cq->wait_completion); 655 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 656 628 657 629 spin_lock_irqsave(&cct->task_lock, flags); 658 630 spin_lock(&cq->task_lock);
-1
drivers/infiniband/hw/ehca/ehca_irq.h
··· 47 47 48 48 #include <linux/interrupt.h> 49 49 #include <linux/types.h> 50 - #include <asm/atomic.h> 51 50 52 51 int ehca_error_data(struct ehca_shca *shca, void *data, u64 resource); 53 52
+18
drivers/infiniband/hw/ehca/ehca_iverbs.h
··· 49 49 int ehca_query_port(struct ib_device *ibdev, u8 port, 50 50 struct ib_port_attr *props); 51 51 52 + int ehca_query_sma_attr(struct ehca_shca *shca, u8 port, 53 + struct ehca_sma_attr *attr); 54 + 52 55 int ehca_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 * pkey); 53 56 54 57 int ehca_query_gid(struct ib_device *ibdev, u8 port, int index, ··· 156 153 157 154 int ehca_post_recv(struct ib_qp *qp, struct ib_recv_wr *recv_wr, 158 155 struct ib_recv_wr **bad_recv_wr); 156 + 157 + int ehca_post_srq_recv(struct ib_srq *srq, 158 + struct ib_recv_wr *recv_wr, 159 + struct ib_recv_wr **bad_recv_wr); 160 + 161 + struct ib_srq *ehca_create_srq(struct ib_pd *pd, 162 + struct ib_srq_init_attr *init_attr, 163 + struct ib_udata *udata); 164 + 165 + int ehca_modify_srq(struct ib_srq *srq, struct ib_srq_attr *attr, 166 + enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); 167 + 168 + int ehca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr); 169 + 170 + int ehca_destroy_srq(struct ib_srq *srq); 159 171 160 172 u64 ehca_define_sqp(struct ehca_shca *shca, struct ehca_qp *ibqp, 161 173 struct ib_qp_init_attr *qp_init_attr);
+76 -22
drivers/infiniband/hw/ehca/ehca_main.c
··· 94 94 MODULE_PARM_DESC(static_rate, 95 95 "set permanent static rate (default: disabled)"); 96 96 MODULE_PARM_DESC(scaling_code, 97 - "set scaling code (0: disabled, 1: enabled/default)"); 97 + "set scaling code (0: disabled/default, 1: enabled)"); 98 98 99 - spinlock_t ehca_qp_idr_lock; 100 - spinlock_t ehca_cq_idr_lock; 101 - spinlock_t hcall_lock; 99 + DEFINE_RWLOCK(ehca_qp_idr_lock); 100 + DEFINE_RWLOCK(ehca_cq_idr_lock); 102 101 DEFINE_IDR(ehca_qp_idr); 103 102 DEFINE_IDR(ehca_cq_idr); 104 103 105 - 106 - static struct list_head shca_list; /* list of all registered ehcas */ 107 - static spinlock_t shca_list_lock; 104 + static LIST_HEAD(shca_list); /* list of all registered ehcas */ 105 + static DEFINE_SPINLOCK(shca_list_lock); 108 106 109 107 static struct timer_list poll_eqs_timer; 110 108 ··· 203 205 #define EHCA_HCAAVER EHCA_BMASK_IBM(32,39) 204 206 #define EHCA_REVID EHCA_BMASK_IBM(40,63) 205 207 208 + static struct cap_descr { 209 + u64 mask; 210 + char *descr; 211 + } hca_cap_descr[] = { 212 + { HCA_CAP_AH_PORT_NR_CHECK, "HCA_CAP_AH_PORT_NR_CHECK" }, 213 + { HCA_CAP_ATOMIC, "HCA_CAP_ATOMIC" }, 214 + { HCA_CAP_AUTO_PATH_MIG, "HCA_CAP_AUTO_PATH_MIG" }, 215 + { HCA_CAP_BAD_P_KEY_CTR, "HCA_CAP_BAD_P_KEY_CTR" }, 216 + { HCA_CAP_SQD_RTS_PORT_CHANGE, "HCA_CAP_SQD_RTS_PORT_CHANGE" }, 217 + { HCA_CAP_CUR_QP_STATE_MOD, "HCA_CAP_CUR_QP_STATE_MOD" }, 218 + { HCA_CAP_INIT_TYPE, "HCA_CAP_INIT_TYPE" }, 219 + { HCA_CAP_PORT_ACTIVE_EVENT, "HCA_CAP_PORT_ACTIVE_EVENT" }, 220 + { HCA_CAP_Q_KEY_VIOL_CTR, "HCA_CAP_Q_KEY_VIOL_CTR" }, 221 + { HCA_CAP_WQE_RESIZE, "HCA_CAP_WQE_RESIZE" }, 222 + { HCA_CAP_RAW_PACKET_MCAST, "HCA_CAP_RAW_PACKET_MCAST" }, 223 + { HCA_CAP_SHUTDOWN_PORT, "HCA_CAP_SHUTDOWN_PORT" }, 224 + { HCA_CAP_RC_LL_QP, "HCA_CAP_RC_LL_QP" }, 225 + { HCA_CAP_SRQ, "HCA_CAP_SRQ" }, 226 + { HCA_CAP_UD_LL_QP, "HCA_CAP_UD_LL_QP" }, 227 + { HCA_CAP_RESIZE_MR, "HCA_CAP_RESIZE_MR" }, 228 + { HCA_CAP_MINI_QP, "HCA_CAP_MINI_QP" }, 229 + }; 230 + 206 231 int ehca_sense_attributes(struct ehca_shca *shca) 207 232 { 208 - int ret = 0; 233 + int i, ret = 0; 209 234 u64 h_ret; 210 235 struct hipz_query_hca *rblock; 236 + struct hipz_query_port *port; 211 237 212 238 rblock = ehca_alloc_fw_ctrlblock(GFP_KERNEL); 213 239 if (!rblock) { ··· 244 222 ehca_gen_err("Cannot query device properties. h_ret=%lx", 245 223 h_ret); 246 224 ret = -EPERM; 247 - goto num_ports1; 225 + goto sense_attributes1; 248 226 } 249 227 250 228 if (ehca_nr_ports == 1) ··· 264 242 ehca_gen_dbg(" ... hardware version=%x:%x", hcaaver, revid); 265 243 266 244 if ((hcaaver == 1) && (revid == 0)) 267 - shca->hw_level = 0; 245 + shca->hw_level = 0x11; 268 246 else if ((hcaaver == 1) && (revid == 1)) 269 - shca->hw_level = 1; 247 + shca->hw_level = 0x12; 270 248 else if ((hcaaver == 1) && (revid == 2)) 271 - shca->hw_level = 2; 249 + shca->hw_level = 0x13; 250 + else if ((hcaaver == 2) && (revid == 0)) 251 + shca->hw_level = 0x21; 252 + else if ((hcaaver == 2) && (revid == 0x10)) 253 + shca->hw_level = 0x22; 254 + else { 255 + ehca_gen_warn("unknown hardware version" 256 + " - assuming default level"); 257 + shca->hw_level = 0x22; 258 + } 272 259 } 273 260 ehca_gen_dbg(" ... hardware level=%x", shca->hw_level); 274 261 275 262 shca->sport[0].rate = IB_RATE_30_GBPS; 276 263 shca->sport[1].rate = IB_RATE_30_GBPS; 277 264 278 - num_ports1: 265 + shca->hca_cap = rblock->hca_cap_indicators; 266 + ehca_gen_dbg(" ... HCA capabilities:"); 267 + for (i = 0; i < ARRAY_SIZE(hca_cap_descr); i++) 268 + if (EHCA_BMASK_GET(hca_cap_descr[i].mask, shca->hca_cap)) 269 + ehca_gen_dbg(" %s", hca_cap_descr[i].descr); 270 + 271 + port = (struct hipz_query_port *) rblock; 272 + h_ret = hipz_h_query_port(shca->ipz_hca_handle, 1, port); 273 + if (h_ret != H_SUCCESS) { 274 + ehca_gen_err("Cannot query port properties. h_ret=%lx", 275 + h_ret); 276 + ret = -EPERM; 277 + goto sense_attributes1; 278 + } 279 + 280 + shca->max_mtu = port->max_mtu; 281 + 282 + sense_attributes1: 279 283 ehca_free_fw_ctrlblock(rblock); 280 284 return ret; 281 285 } ··· 341 293 strlcpy(shca->ib_device.name, "ehca%d", IB_DEVICE_NAME_MAX); 342 294 shca->ib_device.owner = THIS_MODULE; 343 295 344 - shca->ib_device.uverbs_abi_ver = 6; 296 + shca->ib_device.uverbs_abi_ver = 7; 345 297 shca->ib_device.uverbs_cmd_mask = 346 298 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | 347 299 (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) | ··· 408 360 shca->ib_device.detach_mcast = ehca_detach_mcast; 409 361 /* shca->ib_device.process_mad = ehca_process_mad; */ 410 362 shca->ib_device.mmap = ehca_mmap; 363 + 364 + if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { 365 + shca->ib_device.uverbs_cmd_mask |= 366 + (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) | 367 + (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) | 368 + (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) | 369 + (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ); 370 + 371 + shca->ib_device.create_srq = ehca_create_srq; 372 + shca->ib_device.modify_srq = ehca_modify_srq; 373 + shca->ib_device.query_srq = ehca_query_srq; 374 + shca->ib_device.destroy_srq = ehca_destroy_srq; 375 + shca->ib_device.post_srq_recv = ehca_post_srq_recv; 376 + } 411 377 412 378 return ret; 413 379 } ··· 862 800 863 801 printk(KERN_INFO "eHCA Infiniband Device Driver " 864 802 "(Rel.: SVNEHCA_0023)\n"); 865 - idr_init(&ehca_qp_idr); 866 - idr_init(&ehca_cq_idr); 867 - spin_lock_init(&ehca_qp_idr_lock); 868 - spin_lock_init(&ehca_cq_idr_lock); 869 - spin_lock_init(&hcall_lock); 870 - 871 - INIT_LIST_HEAD(&shca_list); 872 - spin_lock_init(&shca_list_lock); 873 803 874 804 if ((ret = ehca_create_comp_pool())) { 875 805 ehca_gen_err("Cannot create comp pool.");
+533 -218
drivers/infiniband/hw/ehca/ehca_qp.c
··· 3 3 * 4 4 * QP functions 5 5 * 6 - * Authors: Waleri Fomin <fomin@de.ibm.com> 6 + * Authors: Joachim Fenkes <fenkes@de.ibm.com> 7 + * Stefan Roscher <stefan.roscher@de.ibm.com> 8 + * Waleri Fomin <fomin@de.ibm.com> 7 9 * Hoang-Nam Nguyen <hnguyen@de.ibm.com> 8 10 * Reinhard Ernst <rernst@de.ibm.com> 9 11 * Heiko J Schick <schickhj@de.ibm.com> ··· 236 234 return index; 237 235 } 238 236 239 - enum ehca_service_type { 240 - ST_RC = 0, 241 - ST_UC = 1, 242 - ST_RD = 2, 243 - ST_UD = 3 244 - }; 245 - 246 237 /* 247 238 * ibqptype2servicetype returns hcp service type corresponding to given 248 239 * ib qp type used by create_qp() ··· 263 268 } 264 269 265 270 /* 266 - * init_qp_queues initializes/constructs r/squeue and registers queue pages. 271 + * init userspace queue info from ipz_queue data 267 272 */ 268 - static inline int init_qp_queues(struct ehca_shca *shca, 269 - struct ehca_qp *my_qp, 270 - int nr_sq_pages, 271 - int nr_rq_pages, 272 - int swqe_size, 273 - int rwqe_size, 274 - int nr_send_sges, int nr_receive_sges) 273 + static inline void queue2resp(struct ipzu_queue_resp *resp, 274 + struct ipz_queue *queue) 275 + { 276 + resp->qe_size = queue->qe_size; 277 + resp->act_nr_of_sg = queue->act_nr_of_sg; 278 + resp->queue_length = queue->queue_length; 279 + resp->pagesize = queue->pagesize; 280 + resp->toggle_state = queue->toggle_state; 281 + } 282 + 283 + static inline int ll_qp_msg_size(int nr_sge) 284 + { 285 + return 128 << nr_sge; 286 + } 287 + 288 + /* 289 + * init_qp_queue initializes/constructs r/squeue and registers queue pages. 290 + */ 291 + static inline int init_qp_queue(struct ehca_shca *shca, 292 + struct ehca_qp *my_qp, 293 + struct ipz_queue *queue, 294 + int q_type, 295 + u64 expected_hret, 296 + int nr_q_pages, 297 + int wqe_size, 298 + int nr_sges) 275 299 { 276 300 int ret, cnt, ipz_rc; 277 301 void *vpage; ··· 298 284 struct ib_device *ib_dev = &shca->ib_device; 299 285 struct ipz_adapter_handle ipz_hca_handle = shca->ipz_hca_handle; 300 286 301 - ipz_rc = ipz_queue_ctor(&my_qp->ipz_squeue, 302 - nr_sq_pages, 303 - EHCA_PAGESIZE, swqe_size, nr_send_sges); 287 + if (!nr_q_pages) 288 + return 0; 289 + 290 + ipz_rc = ipz_queue_ctor(queue, nr_q_pages, EHCA_PAGESIZE, 291 + wqe_size, nr_sges); 304 292 if (!ipz_rc) { 305 - ehca_err(ib_dev,"Cannot allocate page for squeue. ipz_rc=%x", 293 + ehca_err(ib_dev, "Cannot allocate page for queue. ipz_rc=%x", 306 294 ipz_rc); 307 295 return -EBUSY; 308 296 } 309 297 310 - ipz_rc = ipz_queue_ctor(&my_qp->ipz_rqueue, 311 - nr_rq_pages, 312 - EHCA_PAGESIZE, rwqe_size, nr_receive_sges); 313 - if (!ipz_rc) { 314 - ehca_err(ib_dev, "Cannot allocate page for rqueue. ipz_rc=%x", 315 - ipz_rc); 316 - ret = -EBUSY; 317 - goto init_qp_queues0; 318 - } 319 - /* register SQ pages */ 320 - for (cnt = 0; cnt < nr_sq_pages; cnt++) { 321 - vpage = ipz_qpageit_get_inc(&my_qp->ipz_squeue); 298 + /* register queue pages */ 299 + for (cnt = 0; cnt < nr_q_pages; cnt++) { 300 + vpage = ipz_qpageit_get_inc(queue); 322 301 if (!vpage) { 323 - ehca_err(ib_dev, "SQ ipz_qpageit_get_inc() " 302 + ehca_err(ib_dev, "ipz_qpageit_get_inc() " 324 303 "failed p_vpage= %p", vpage); 325 304 ret = -EINVAL; 326 - goto init_qp_queues1; 305 + goto init_qp_queue1; 327 306 } 328 307 rpage = virt_to_abs(vpage); 329 308 330 309 h_ret = hipz_h_register_rpage_qp(ipz_hca_handle, 331 310 my_qp->ipz_qp_handle, 332 - &my_qp->pf, 0, 0, 311 + NULL, 0, q_type, 333 312 rpage, 1, 334 313 my_qp->galpas.kernel); 335 - if (h_ret < H_SUCCESS) { 336 - ehca_err(ib_dev, "SQ hipz_qp_register_rpage()" 337 - " failed rc=%lx", h_ret); 338 - ret = ehca2ib_return_code(h_ret); 339 - goto init_qp_queues1; 340 - } 341 - } 342 - 343 - ipz_qeit_reset(&my_qp->ipz_squeue); 344 - 345 - /* register RQ pages */ 346 - for (cnt = 0; cnt < nr_rq_pages; cnt++) { 347 - vpage = ipz_qpageit_get_inc(&my_qp->ipz_rqueue); 348 - if (!vpage) { 349 - ehca_err(ib_dev, "RQ ipz_qpageit_get_inc() " 350 - "failed p_vpage = %p", vpage); 351 - ret = -EINVAL; 352 - goto init_qp_queues1; 353 - } 354 - 355 - rpage = virt_to_abs(vpage); 356 - 357 - h_ret = hipz_h_register_rpage_qp(ipz_hca_handle, 358 - my_qp->ipz_qp_handle, 359 - &my_qp->pf, 0, 1, 360 - rpage, 1,my_qp->galpas.kernel); 361 - if (h_ret < H_SUCCESS) { 362 - ehca_err(ib_dev, "RQ hipz_qp_register_rpage() failed " 363 - "rc=%lx", h_ret); 364 - ret = ehca2ib_return_code(h_ret); 365 - goto init_qp_queues1; 366 - } 367 - if (cnt == (nr_rq_pages - 1)) { /* last page! */ 368 - if (h_ret != H_SUCCESS) { 369 - ehca_err(ib_dev, "RQ hipz_qp_register_rpage() " 314 + if (cnt == (nr_q_pages - 1)) { /* last page! */ 315 + if (h_ret != expected_hret) { 316 + ehca_err(ib_dev, "hipz_qp_register_rpage() " 370 317 "h_ret= %lx ", h_ret); 371 318 ret = ehca2ib_return_code(h_ret); 372 - goto init_qp_queues1; 319 + goto init_qp_queue1; 373 320 } 374 321 vpage = ipz_qpageit_get_inc(&my_qp->ipz_rqueue); 375 322 if (vpage) { 376 323 ehca_err(ib_dev, "ipz_qpageit_get_inc() " 377 324 "should not succeed vpage=%p", vpage); 378 325 ret = -EINVAL; 379 - goto init_qp_queues1; 326 + goto init_qp_queue1; 380 327 } 381 328 } else { 382 329 if (h_ret != H_PAGE_REGISTERED) { 383 - ehca_err(ib_dev, "RQ hipz_qp_register_rpage() " 330 + ehca_err(ib_dev, "hipz_qp_register_rpage() " 384 331 "h_ret= %lx ", h_ret); 385 332 ret = ehca2ib_return_code(h_ret); 386 - goto init_qp_queues1; 333 + goto init_qp_queue1; 387 334 } 388 335 } 389 336 } 390 337 391 - ipz_qeit_reset(&my_qp->ipz_rqueue); 338 + ipz_qeit_reset(queue); 392 339 393 340 return 0; 394 341 395 - init_qp_queues1: 396 - ipz_queue_dtor(&my_qp->ipz_rqueue); 397 - init_qp_queues0: 398 - ipz_queue_dtor(&my_qp->ipz_squeue); 342 + init_qp_queue1: 343 + ipz_queue_dtor(queue); 399 344 return ret; 400 345 } 401 346 402 - struct ib_qp *ehca_create_qp(struct ib_pd *pd, 403 - struct ib_qp_init_attr *init_attr, 404 - struct ib_udata *udata) 347 + /* 348 + * Create an ib_qp struct that is either a QP or an SRQ, depending on 349 + * the value of the is_srq parameter. If init_attr and srq_init_attr share 350 + * fields, the field out of init_attr is used. 351 + */ 352 + struct ehca_qp *internal_create_qp(struct ib_pd *pd, 353 + struct ib_qp_init_attr *init_attr, 354 + struct ib_srq_init_attr *srq_init_attr, 355 + struct ib_udata *udata, int is_srq) 405 356 { 406 - static int da_rc_msg_size[]={ 128, 256, 512, 1024, 2048, 4096 }; 407 - static int da_ud_sq_msg_size[]={ 128, 384, 896, 1920, 3968 }; 408 357 struct ehca_qp *my_qp; 409 358 struct ehca_pd *my_pd = container_of(pd, struct ehca_pd, ib_pd); 410 359 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca, 411 360 ib_device); 412 361 struct ib_ucontext *context = NULL; 413 362 u64 h_ret; 414 - int max_send_sge, max_recv_sge, ret; 363 + int is_llqp = 0, has_srq = 0; 364 + int qp_type, max_send_sge, max_recv_sge, ret; 415 365 416 366 /* h_call's out parameters */ 417 367 struct ehca_alloc_qp_parms parms; 418 - u32 swqe_size = 0, rwqe_size = 0; 419 - u8 daqp_completion, isdaqp; 368 + u32 swqe_size = 0, rwqe_size = 0, ib_qp_num; 420 369 unsigned long flags; 370 + 371 + memset(&parms, 0, sizeof(parms)); 372 + qp_type = init_attr->qp_type; 421 373 422 374 if (init_attr->sq_sig_type != IB_SIGNAL_REQ_WR && 423 375 init_attr->sq_sig_type != IB_SIGNAL_ALL_WR) { ··· 392 412 return ERR_PTR(-EINVAL); 393 413 } 394 414 395 - /* save daqp completion bits */ 396 - daqp_completion = init_attr->qp_type & 0x60; 397 - /* save daqp bit */ 398 - isdaqp = (init_attr->qp_type & 0x80) ? 1 : 0; 399 - init_attr->qp_type = init_attr->qp_type & 0x1F; 415 + /* save LLQP info */ 416 + if (qp_type & 0x80) { 417 + is_llqp = 1; 418 + parms.ext_type = EQPT_LLQP; 419 + parms.ll_comp_flags = qp_type & LLQP_COMP_MASK; 420 + } 421 + qp_type &= 0x1F; 422 + init_attr->qp_type &= 0x1F; 400 423 401 - if (init_attr->qp_type != IB_QPT_UD && 402 - init_attr->qp_type != IB_QPT_SMI && 403 - init_attr->qp_type != IB_QPT_GSI && 404 - init_attr->qp_type != IB_QPT_UC && 405 - init_attr->qp_type != IB_QPT_RC) { 406 - ehca_err(pd->device, "wrong QP Type=%x", init_attr->qp_type); 424 + /* handle SRQ base QPs */ 425 + if (init_attr->srq) { 426 + struct ehca_qp *my_srq = 427 + container_of(init_attr->srq, struct ehca_qp, ib_srq); 428 + 429 + has_srq = 1; 430 + parms.ext_type = EQPT_SRQBASE; 431 + parms.srq_qpn = my_srq->real_qp_num; 432 + parms.srq_token = my_srq->token; 433 + } 434 + 435 + if (is_llqp && has_srq) { 436 + ehca_err(pd->device, "LLQPs can't have an SRQ"); 407 437 return ERR_PTR(-EINVAL); 408 438 } 409 - if ((init_attr->qp_type != IB_QPT_RC && init_attr->qp_type != IB_QPT_UD) 410 - && isdaqp) { 411 - ehca_err(pd->device, "unsupported LL QP Type=%x", 412 - init_attr->qp_type); 439 + 440 + /* handle SRQs */ 441 + if (is_srq) { 442 + parms.ext_type = EQPT_SRQ; 443 + parms.srq_limit = srq_init_attr->attr.srq_limit; 444 + if (init_attr->cap.max_recv_sge > 3) { 445 + ehca_err(pd->device, "no more than three SGEs " 446 + "supported for SRQ pd=%p max_sge=%x", 447 + pd, init_attr->cap.max_recv_sge); 448 + return ERR_PTR(-EINVAL); 449 + } 450 + } 451 + 452 + /* check QP type */ 453 + if (qp_type != IB_QPT_UD && 454 + qp_type != IB_QPT_UC && 455 + qp_type != IB_QPT_RC && 456 + qp_type != IB_QPT_SMI && 457 + qp_type != IB_QPT_GSI) { 458 + ehca_err(pd->device, "wrong QP Type=%x", qp_type); 413 459 return ERR_PTR(-EINVAL); 414 - } else if (init_attr->qp_type == IB_QPT_RC && isdaqp && 415 - (init_attr->cap.max_send_wr > 255 || 416 - init_attr->cap.max_recv_wr > 255 )) { 417 - ehca_err(pd->device, "Invalid Number of max_sq_wr =%x " 418 - "or max_rq_wr=%x for QP Type=%x", 419 - init_attr->cap.max_send_wr, 420 - init_attr->cap.max_recv_wr,init_attr->qp_type); 421 - return ERR_PTR(-EINVAL); 422 - } else if (init_attr->qp_type == IB_QPT_UD && isdaqp && 423 - init_attr->cap.max_send_wr > 255) { 424 - ehca_err(pd->device, 425 - "Invalid Number of max_send_wr=%x for UD QP_TYPE=%x", 426 - init_attr->cap.max_send_wr, init_attr->qp_type); 427 - return ERR_PTR(-EINVAL); 460 + } 461 + 462 + if (is_llqp) { 463 + switch (qp_type) { 464 + case IB_QPT_RC: 465 + if ((init_attr->cap.max_send_wr > 255) || 466 + (init_attr->cap.max_recv_wr > 255)) { 467 + ehca_err(pd->device, 468 + "Invalid Number of max_sq_wr=%x " 469 + "or max_rq_wr=%x for RC LLQP", 470 + init_attr->cap.max_send_wr, 471 + init_attr->cap.max_recv_wr); 472 + return ERR_PTR(-EINVAL); 473 + } 474 + break; 475 + case IB_QPT_UD: 476 + if (!EHCA_BMASK_GET(HCA_CAP_UD_LL_QP, shca->hca_cap)) { 477 + ehca_err(pd->device, "UD LLQP not supported " 478 + "by this adapter"); 479 + return ERR_PTR(-ENOSYS); 480 + } 481 + if (!(init_attr->cap.max_send_sge <= 5 482 + && init_attr->cap.max_send_sge >= 1 483 + && init_attr->cap.max_recv_sge <= 5 484 + && init_attr->cap.max_recv_sge >= 1)) { 485 + ehca_err(pd->device, 486 + "Invalid Number of max_send_sge=%x " 487 + "or max_recv_sge=%x for UD LLQP", 488 + init_attr->cap.max_send_sge, 489 + init_attr->cap.max_recv_sge); 490 + return ERR_PTR(-EINVAL); 491 + } else if (init_attr->cap.max_send_wr > 255) { 492 + ehca_err(pd->device, 493 + "Invalid Number of " 494 + "ax_send_wr=%x for UD QP_TYPE=%x", 495 + init_attr->cap.max_send_wr, qp_type); 496 + return ERR_PTR(-EINVAL); 497 + } 498 + break; 499 + default: 500 + ehca_err(pd->device, "unsupported LL QP Type=%x", 501 + qp_type); 502 + return ERR_PTR(-EINVAL); 503 + break; 504 + } 428 505 } 429 506 430 507 if (pd->uobject && udata) ··· 493 456 return ERR_PTR(-ENOMEM); 494 457 } 495 458 496 - memset (&parms, 0, sizeof(struct ehca_alloc_qp_parms)); 497 459 spin_lock_init(&my_qp->spinlock_s); 498 460 spin_lock_init(&my_qp->spinlock_r); 461 + my_qp->qp_type = qp_type; 462 + my_qp->ext_type = parms.ext_type; 499 463 500 - my_qp->recv_cq = 501 - container_of(init_attr->recv_cq, struct ehca_cq, ib_cq); 502 - my_qp->send_cq = 503 - container_of(init_attr->send_cq, struct ehca_cq, ib_cq); 504 - 505 - my_qp->init_attr = *init_attr; 464 + if (init_attr->recv_cq) 465 + my_qp->recv_cq = 466 + container_of(init_attr->recv_cq, struct ehca_cq, ib_cq); 467 + if (init_attr->send_cq) 468 + my_qp->send_cq = 469 + container_of(init_attr->send_cq, struct ehca_cq, ib_cq); 506 470 507 471 do { 508 472 if (!idr_pre_get(&ehca_qp_idr, GFP_KERNEL)) { ··· 512 474 goto create_qp_exit0; 513 475 } 514 476 515 - spin_lock_irqsave(&ehca_qp_idr_lock, flags); 477 + write_lock_irqsave(&ehca_qp_idr_lock, flags); 516 478 ret = idr_get_new(&ehca_qp_idr, my_qp, &my_qp->token); 517 - spin_unlock_irqrestore(&ehca_qp_idr_lock, flags); 479 + write_unlock_irqrestore(&ehca_qp_idr_lock, flags); 518 480 519 481 } while (ret == -EAGAIN); 520 482 ··· 524 486 goto create_qp_exit0; 525 487 } 526 488 527 - parms.servicetype = ibqptype2servicetype(init_attr->qp_type); 489 + parms.servicetype = ibqptype2servicetype(qp_type); 528 490 if (parms.servicetype < 0) { 529 491 ret = -EINVAL; 530 - ehca_err(pd->device, "Invalid qp_type=%x", init_attr->qp_type); 492 + ehca_err(pd->device, "Invalid qp_type=%x", qp_type); 531 493 goto create_qp_exit0; 532 494 } 533 495 ··· 539 501 /* UD_AV CIRCUMVENTION */ 540 502 max_send_sge = init_attr->cap.max_send_sge; 541 503 max_recv_sge = init_attr->cap.max_recv_sge; 542 - if (IB_QPT_UD == init_attr->qp_type || 543 - IB_QPT_GSI == init_attr->qp_type || 544 - IB_QPT_SMI == init_attr->qp_type) { 504 + if (parms.servicetype == ST_UD && !is_llqp) { 545 505 max_send_sge += 2; 546 506 max_recv_sge += 2; 547 507 } 548 508 549 - parms.ipz_eq_handle = shca->eq.ipz_eq_handle; 550 - parms.daqp_ctrl = isdaqp | daqp_completion; 509 + parms.token = my_qp->token; 510 + parms.eq_handle = shca->eq.ipz_eq_handle; 551 511 parms.pd = my_pd->fw_pd; 552 - parms.max_recv_sge = max_recv_sge; 512 + if (my_qp->send_cq) 513 + parms.send_cq_handle = my_qp->send_cq->ipz_cq_handle; 514 + if (my_qp->recv_cq) 515 + parms.recv_cq_handle = my_qp->recv_cq->ipz_cq_handle; 516 + 517 + parms.max_send_wr = init_attr->cap.max_send_wr; 518 + parms.max_recv_wr = init_attr->cap.max_recv_wr; 553 519 parms.max_send_sge = max_send_sge; 520 + parms.max_recv_sge = max_recv_sge; 554 521 555 - h_ret = hipz_h_alloc_resource_qp(shca->ipz_hca_handle, my_qp, &parms); 556 - 522 + h_ret = hipz_h_alloc_resource_qp(shca->ipz_hca_handle, &parms); 557 523 if (h_ret != H_SUCCESS) { 558 524 ehca_err(pd->device, "h_alloc_resource_qp() failed h_ret=%lx", 559 525 h_ret); ··· 565 523 goto create_qp_exit1; 566 524 } 567 525 568 - my_qp->ib_qp.qp_num = my_qp->real_qp_num; 526 + ib_qp_num = my_qp->real_qp_num = parms.real_qp_num; 527 + my_qp->ipz_qp_handle = parms.qp_handle; 528 + my_qp->galpas = parms.galpas; 569 529 570 - switch (init_attr->qp_type) { 530 + switch (qp_type) { 571 531 case IB_QPT_RC: 572 - if (isdaqp == 0) { 532 + if (!is_llqp) { 573 533 swqe_size = offsetof(struct ehca_wqe, u.nud.sg_list[ 574 534 (parms.act_nr_send_sges)]); 575 535 rwqe_size = offsetof(struct ehca_wqe, u.nud.sg_list[ 576 536 (parms.act_nr_recv_sges)]); 577 - } else { /* for daqp we need to use msg size, not wqe size */ 578 - swqe_size = da_rc_msg_size[max_send_sge]; 579 - rwqe_size = da_rc_msg_size[max_recv_sge]; 537 + } else { /* for LLQP we need to use msg size, not wqe size */ 538 + swqe_size = ll_qp_msg_size(max_send_sge); 539 + rwqe_size = ll_qp_msg_size(max_recv_sge); 580 540 parms.act_nr_send_sges = 1; 581 541 parms.act_nr_recv_sges = 1; 582 542 } ··· 593 549 case IB_QPT_UD: 594 550 case IB_QPT_GSI: 595 551 case IB_QPT_SMI: 596 - /* UD circumvention */ 597 - parms.act_nr_recv_sges -= 2; 598 - parms.act_nr_send_sges -= 2; 599 - if (isdaqp) { 600 - swqe_size = da_ud_sq_msg_size[max_send_sge]; 601 - rwqe_size = da_rc_msg_size[max_recv_sge]; 552 + if (is_llqp) { 553 + swqe_size = ll_qp_msg_size(parms.act_nr_send_sges); 554 + rwqe_size = ll_qp_msg_size(parms.act_nr_recv_sges); 602 555 parms.act_nr_send_sges = 1; 603 556 parms.act_nr_recv_sges = 1; 604 557 } else { 558 + /* UD circumvention */ 559 + parms.act_nr_send_sges -= 2; 560 + parms.act_nr_recv_sges -= 2; 605 561 swqe_size = offsetof(struct ehca_wqe, 606 562 u.ud_av.sg_list[parms.act_nr_send_sges]); 607 563 rwqe_size = offsetof(struct ehca_wqe, 608 564 u.ud_av.sg_list[parms.act_nr_recv_sges]); 609 565 } 610 566 611 - if (IB_QPT_GSI == init_attr->qp_type || 612 - IB_QPT_SMI == init_attr->qp_type) { 567 + if (IB_QPT_GSI == qp_type || IB_QPT_SMI == qp_type) { 613 568 parms.act_nr_send_wqes = init_attr->cap.max_send_wr; 614 569 parms.act_nr_recv_wqes = init_attr->cap.max_recv_wr; 615 570 parms.act_nr_send_sges = init_attr->cap.max_send_sge; 616 571 parms.act_nr_recv_sges = init_attr->cap.max_recv_sge; 617 - my_qp->ib_qp.qp_num = 618 - (init_attr->qp_type == IB_QPT_SMI) ? 0 : 1; 572 + ib_qp_num = (qp_type == IB_QPT_SMI) ? 0 : 1; 619 573 } 620 574 621 575 break; ··· 622 580 break; 623 581 } 624 582 625 - /* initializes r/squeue and registers queue pages */ 626 - ret = init_qp_queues(shca, my_qp, 627 - parms.nr_sq_pages, parms.nr_rq_pages, 628 - swqe_size, rwqe_size, 629 - parms.act_nr_send_sges, parms.act_nr_recv_sges); 630 - if (ret) { 631 - ehca_err(pd->device, 632 - "Couldn't initialize r/squeue and pages ret=%x", ret); 633 - goto create_qp_exit2; 583 + /* initialize r/squeue and register queue pages */ 584 + if (HAS_SQ(my_qp)) { 585 + ret = init_qp_queue( 586 + shca, my_qp, &my_qp->ipz_squeue, 0, 587 + HAS_RQ(my_qp) ? H_PAGE_REGISTERED : H_SUCCESS, 588 + parms.nr_sq_pages, swqe_size, 589 + parms.act_nr_send_sges); 590 + if (ret) { 591 + ehca_err(pd->device, "Couldn't initialize squeue " 592 + "and pages ret=%x", ret); 593 + goto create_qp_exit2; 594 + } 634 595 } 635 596 636 - my_qp->ib_qp.pd = &my_pd->ib_pd; 637 - my_qp->ib_qp.device = my_pd->ib_pd.device; 597 + if (HAS_RQ(my_qp)) { 598 + ret = init_qp_queue( 599 + shca, my_qp, &my_qp->ipz_rqueue, 1, 600 + H_SUCCESS, parms.nr_rq_pages, rwqe_size, 601 + parms.act_nr_recv_sges); 602 + if (ret) { 603 + ehca_err(pd->device, "Couldn't initialize rqueue " 604 + "and pages ret=%x", ret); 605 + goto create_qp_exit3; 606 + } 607 + } 638 608 639 - my_qp->ib_qp.recv_cq = init_attr->recv_cq; 640 - my_qp->ib_qp.send_cq = init_attr->send_cq; 609 + if (is_srq) { 610 + my_qp->ib_srq.pd = &my_pd->ib_pd; 611 + my_qp->ib_srq.device = my_pd->ib_pd.device; 641 612 642 - my_qp->ib_qp.qp_type = init_attr->qp_type; 613 + my_qp->ib_srq.srq_context = init_attr->qp_context; 614 + my_qp->ib_srq.event_handler = init_attr->event_handler; 615 + } else { 616 + my_qp->ib_qp.qp_num = ib_qp_num; 617 + my_qp->ib_qp.pd = &my_pd->ib_pd; 618 + my_qp->ib_qp.device = my_pd->ib_pd.device; 643 619 644 - my_qp->qp_type = init_attr->qp_type; 645 - my_qp->ib_qp.srq = init_attr->srq; 620 + my_qp->ib_qp.recv_cq = init_attr->recv_cq; 621 + my_qp->ib_qp.send_cq = init_attr->send_cq; 646 622 647 - my_qp->ib_qp.qp_context = init_attr->qp_context; 648 - my_qp->ib_qp.event_handler = init_attr->event_handler; 623 + my_qp->ib_qp.qp_type = qp_type; 624 + my_qp->ib_qp.srq = init_attr->srq; 625 + 626 + my_qp->ib_qp.qp_context = init_attr->qp_context; 627 + my_qp->ib_qp.event_handler = init_attr->event_handler; 628 + } 649 629 650 630 init_attr->cap.max_inline_data = 0; /* not supported yet */ 651 631 init_attr->cap.max_recv_sge = parms.act_nr_recv_sges; 652 632 init_attr->cap.max_recv_wr = parms.act_nr_recv_wqes; 653 633 init_attr->cap.max_send_sge = parms.act_nr_send_sges; 654 634 init_attr->cap.max_send_wr = parms.act_nr_send_wqes; 635 + my_qp->init_attr = *init_attr; 655 636 656 637 /* NOTE: define_apq0() not supported yet */ 657 - if (init_attr->qp_type == IB_QPT_GSI) { 638 + if (qp_type == IB_QPT_GSI) { 658 639 h_ret = ehca_define_sqp(shca, my_qp, init_attr); 659 640 if (h_ret != H_SUCCESS) { 660 641 ehca_err(pd->device, "ehca_define_sqp() failed rc=%lx", 661 642 h_ret); 662 643 ret = ehca2ib_return_code(h_ret); 663 - goto create_qp_exit3; 644 + goto create_qp_exit4; 664 645 } 665 646 } 666 - if (init_attr->send_cq) { 667 - struct ehca_cq *cq = container_of(init_attr->send_cq, 668 - struct ehca_cq, ib_cq); 669 - ret = ehca_cq_assign_qp(cq, my_qp); 647 + 648 + if (my_qp->send_cq) { 649 + ret = ehca_cq_assign_qp(my_qp->send_cq, my_qp); 670 650 if (ret) { 671 651 ehca_err(pd->device, "Couldn't assign qp to send_cq ret=%x", 672 652 ret); 673 - goto create_qp_exit3; 653 + goto create_qp_exit4; 674 654 } 675 - my_qp->send_cq = cq; 676 655 } 656 + 677 657 /* copy queues, galpa data to user space */ 678 658 if (context && udata) { 679 - struct ipz_queue *ipz_rqueue = &my_qp->ipz_rqueue; 680 - struct ipz_queue *ipz_squeue = &my_qp->ipz_squeue; 681 659 struct ehca_create_qp_resp resp; 682 660 memset(&resp, 0, sizeof(resp)); 683 661 684 662 resp.qp_num = my_qp->real_qp_num; 685 663 resp.token = my_qp->token; 686 664 resp.qp_type = my_qp->qp_type; 665 + resp.ext_type = my_qp->ext_type; 687 666 resp.qkey = my_qp->qkey; 688 667 resp.real_qp_num = my_qp->real_qp_num; 689 - /* rqueue properties */ 690 - resp.ipz_rqueue.qe_size = ipz_rqueue->qe_size; 691 - resp.ipz_rqueue.act_nr_of_sg = ipz_rqueue->act_nr_of_sg; 692 - resp.ipz_rqueue.queue_length = ipz_rqueue->queue_length; 693 - resp.ipz_rqueue.pagesize = ipz_rqueue->pagesize; 694 - resp.ipz_rqueue.toggle_state = ipz_rqueue->toggle_state; 695 - /* squeue properties */ 696 - resp.ipz_squeue.qe_size = ipz_squeue->qe_size; 697 - resp.ipz_squeue.act_nr_of_sg = ipz_squeue->act_nr_of_sg; 698 - resp.ipz_squeue.queue_length = ipz_squeue->queue_length; 699 - resp.ipz_squeue.pagesize = ipz_squeue->pagesize; 700 - resp.ipz_squeue.toggle_state = ipz_squeue->toggle_state; 668 + if (HAS_SQ(my_qp)) 669 + queue2resp(&resp.ipz_squeue, &my_qp->ipz_squeue); 670 + if (HAS_RQ(my_qp)) 671 + queue2resp(&resp.ipz_rqueue, &my_qp->ipz_rqueue); 672 + 701 673 if (ib_copy_to_udata(udata, &resp, sizeof resp)) { 702 674 ehca_err(pd->device, "Copy to udata failed"); 703 675 ret = -EINVAL; 704 - goto create_qp_exit3; 676 + goto create_qp_exit4; 705 677 } 706 678 } 707 679 708 - return &my_qp->ib_qp; 680 + return my_qp; 681 + 682 + create_qp_exit4: 683 + if (HAS_RQ(my_qp)) 684 + ipz_queue_dtor(&my_qp->ipz_rqueue); 709 685 710 686 create_qp_exit3: 711 - ipz_queue_dtor(&my_qp->ipz_rqueue); 712 - ipz_queue_dtor(&my_qp->ipz_squeue); 687 + if (HAS_SQ(my_qp)) 688 + ipz_queue_dtor(&my_qp->ipz_squeue); 713 689 714 690 create_qp_exit2: 715 691 hipz_h_destroy_qp(shca->ipz_hca_handle, my_qp); 716 692 717 693 create_qp_exit1: 718 - spin_lock_irqsave(&ehca_qp_idr_lock, flags); 694 + write_lock_irqsave(&ehca_qp_idr_lock, flags); 719 695 idr_remove(&ehca_qp_idr, my_qp->token); 720 - spin_unlock_irqrestore(&ehca_qp_idr_lock, flags); 696 + write_unlock_irqrestore(&ehca_qp_idr_lock, flags); 721 697 722 698 create_qp_exit0: 723 699 kmem_cache_free(qp_cache, my_qp); 724 700 return ERR_PTR(ret); 701 + } 702 + 703 + struct ib_qp *ehca_create_qp(struct ib_pd *pd, 704 + struct ib_qp_init_attr *qp_init_attr, 705 + struct ib_udata *udata) 706 + { 707 + struct ehca_qp *ret; 708 + 709 + ret = internal_create_qp(pd, qp_init_attr, NULL, udata, 0); 710 + return IS_ERR(ret) ? (struct ib_qp *) ret : &ret->ib_qp; 711 + } 712 + 713 + int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp, 714 + struct ib_uobject *uobject); 715 + 716 + struct ib_srq *ehca_create_srq(struct ib_pd *pd, 717 + struct ib_srq_init_attr *srq_init_attr, 718 + struct ib_udata *udata) 719 + { 720 + struct ib_qp_init_attr qp_init_attr; 721 + struct ehca_qp *my_qp; 722 + struct ib_srq *ret; 723 + struct ehca_shca *shca = container_of(pd->device, struct ehca_shca, 724 + ib_device); 725 + struct hcp_modify_qp_control_block *mqpcb; 726 + u64 hret, update_mask; 727 + 728 + /* For common attributes, internal_create_qp() takes its info 729 + * out of qp_init_attr, so copy all common attrs there. 730 + */ 731 + memset(&qp_init_attr, 0, sizeof(qp_init_attr)); 732 + qp_init_attr.event_handler = srq_init_attr->event_handler; 733 + qp_init_attr.qp_context = srq_init_attr->srq_context; 734 + qp_init_attr.sq_sig_type = IB_SIGNAL_ALL_WR; 735 + qp_init_attr.qp_type = IB_QPT_RC; 736 + qp_init_attr.cap.max_recv_wr = srq_init_attr->attr.max_wr; 737 + qp_init_attr.cap.max_recv_sge = srq_init_attr->attr.max_sge; 738 + 739 + my_qp = internal_create_qp(pd, &qp_init_attr, srq_init_attr, udata, 1); 740 + if (IS_ERR(my_qp)) 741 + return (struct ib_srq *) my_qp; 742 + 743 + /* copy back return values */ 744 + srq_init_attr->attr.max_wr = qp_init_attr.cap.max_recv_wr; 745 + srq_init_attr->attr.max_sge = qp_init_attr.cap.max_recv_sge; 746 + 747 + /* drive SRQ into RTR state */ 748 + mqpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL); 749 + if (!mqpcb) { 750 + ehca_err(pd->device, "Could not get zeroed page for mqpcb " 751 + "ehca_qp=%p qp_num=%x ", my_qp, my_qp->real_qp_num); 752 + ret = ERR_PTR(-ENOMEM); 753 + goto create_srq1; 754 + } 755 + 756 + mqpcb->qp_state = EHCA_QPS_INIT; 757 + mqpcb->prim_phys_port = 1; 758 + update_mask = EHCA_BMASK_SET(MQPCB_MASK_QP_STATE, 1); 759 + hret = hipz_h_modify_qp(shca->ipz_hca_handle, 760 + my_qp->ipz_qp_handle, 761 + &my_qp->pf, 762 + update_mask, 763 + mqpcb, my_qp->galpas.kernel); 764 + if (hret != H_SUCCESS) { 765 + ehca_err(pd->device, "Could not modify SRQ to INIT" 766 + "ehca_qp=%p qp_num=%x hret=%lx", 767 + my_qp, my_qp->real_qp_num, hret); 768 + goto create_srq2; 769 + } 770 + 771 + mqpcb->qp_enable = 1; 772 + update_mask = EHCA_BMASK_SET(MQPCB_MASK_QP_ENABLE, 1); 773 + hret = hipz_h_modify_qp(shca->ipz_hca_handle, 774 + my_qp->ipz_qp_handle, 775 + &my_qp->pf, 776 + update_mask, 777 + mqpcb, my_qp->galpas.kernel); 778 + if (hret != H_SUCCESS) { 779 + ehca_err(pd->device, "Could not enable SRQ" 780 + "ehca_qp=%p qp_num=%x hret=%lx", 781 + my_qp, my_qp->real_qp_num, hret); 782 + goto create_srq2; 783 + } 784 + 785 + mqpcb->qp_state = EHCA_QPS_RTR; 786 + update_mask = EHCA_BMASK_SET(MQPCB_MASK_QP_STATE, 1); 787 + hret = hipz_h_modify_qp(shca->ipz_hca_handle, 788 + my_qp->ipz_qp_handle, 789 + &my_qp->pf, 790 + update_mask, 791 + mqpcb, my_qp->galpas.kernel); 792 + if (hret != H_SUCCESS) { 793 + ehca_err(pd->device, "Could not modify SRQ to RTR" 794 + "ehca_qp=%p qp_num=%x hret=%lx", 795 + my_qp, my_qp->real_qp_num, hret); 796 + goto create_srq2; 797 + } 798 + 799 + return &my_qp->ib_srq; 800 + 801 + create_srq2: 802 + ret = ERR_PTR(ehca2ib_return_code(hret)); 803 + ehca_free_fw_ctrlblock(mqpcb); 804 + 805 + create_srq1: 806 + internal_destroy_qp(pd->device, my_qp, my_qp->ib_srq.uobject); 807 + 808 + return ret; 725 809 } 726 810 727 811 /* ··· 933 765 u64 h_ret; 934 766 int bad_wqe_cnt = 0; 935 767 int squeue_locked = 0; 936 - unsigned long spl_flags = 0; 768 + unsigned long flags = 0; 937 769 938 770 /* do query_qp to obtain current attr values */ 939 771 mqpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL); ··· 1054 886 "ehca_qp=%p qp_num=%x <VALID STATE CHANGE> qp_state_xsit=%x", 1055 887 my_qp, ibqp->qp_num, statetrans); 1056 888 889 + /* eHCA2 rev2 and higher require the SEND_GRH_FLAG to be set 890 + * in non-LL UD QPs. 891 + */ 892 + if ((my_qp->qp_type == IB_QPT_UD) && 893 + (my_qp->ext_type != EQPT_LLQP) && 894 + (statetrans == IB_QPST_INIT2RTR) && 895 + (shca->hw_level >= 0x22)) { 896 + update_mask |= EHCA_BMASK_SET(MQPCB_MASK_SEND_GRH_FLAG, 1); 897 + mqpcb->send_grh_flag = 1; 898 + } 899 + 1057 900 /* sqe -> rts: set purge bit of bad wqe before actual trans */ 1058 901 if ((my_qp->qp_type == IB_QPT_UD || 1059 902 my_qp->qp_type == IB_QPT_GSI || ··· 1074 895 if (!ibqp->uobject) { 1075 896 struct ehca_wqe *wqe; 1076 897 /* lock send queue */ 1077 - spin_lock_irqsave(&my_qp->spinlock_s, spl_flags); 898 + spin_lock_irqsave(&my_qp->spinlock_s, flags); 1078 899 squeue_locked = 1; 1079 900 /* mark next free wqe */ 1080 901 wqe = (struct ehca_wqe*) ··· 1360 1181 1361 1182 modify_qp_exit2: 1362 1183 if (squeue_locked) { /* this means: sqe -> rts */ 1363 - spin_unlock_irqrestore(&my_qp->spinlock_s, spl_flags); 1184 + spin_unlock_irqrestore(&my_qp->spinlock_s, flags); 1364 1185 my_qp->sqerr_purgeflag = 1; 1365 1186 } 1366 1187 ··· 1491 1312 qp_attr->alt_port_num = qpcb->alt_phys_port; 1492 1313 qp_attr->alt_timeout = qpcb->timeout_al; 1493 1314 1315 + qp_attr->max_dest_rd_atomic = qpcb->rdma_nr_atomic_resp_res; 1316 + qp_attr->max_rd_atomic = qpcb->rdma_atomic_outst_dest_qp; 1317 + 1494 1318 /* primary av */ 1495 1319 qp_attr->ah_attr.sl = qpcb->service_level; 1496 1320 ··· 1549 1367 return ret; 1550 1368 } 1551 1369 1552 - int ehca_destroy_qp(struct ib_qp *ibqp) 1370 + int ehca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, 1371 + enum ib_srq_attr_mask attr_mask, struct ib_udata *udata) 1553 1372 { 1554 - struct ehca_qp *my_qp = container_of(ibqp, struct ehca_qp, ib_qp); 1555 - struct ehca_shca *shca = container_of(ibqp->device, struct ehca_shca, 1373 + struct ehca_qp *my_qp = 1374 + container_of(ibsrq, struct ehca_qp, ib_srq); 1375 + struct ehca_pd *my_pd = 1376 + container_of(ibsrq->pd, struct ehca_pd, ib_pd); 1377 + struct ehca_shca *shca = 1378 + container_of(ibsrq->pd->device, struct ehca_shca, ib_device); 1379 + struct hcp_modify_qp_control_block *mqpcb; 1380 + u64 update_mask; 1381 + u64 h_ret; 1382 + int ret = 0; 1383 + 1384 + u32 cur_pid = current->tgid; 1385 + if (my_pd->ib_pd.uobject && my_pd->ib_pd.uobject->context && 1386 + my_pd->ownpid != cur_pid) { 1387 + ehca_err(ibsrq->pd->device, "Invalid caller pid=%x ownpid=%x", 1388 + cur_pid, my_pd->ownpid); 1389 + return -EINVAL; 1390 + } 1391 + 1392 + mqpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL); 1393 + if (!mqpcb) { 1394 + ehca_err(ibsrq->device, "Could not get zeroed page for mqpcb " 1395 + "ehca_qp=%p qp_num=%x ", my_qp, my_qp->real_qp_num); 1396 + return -ENOMEM; 1397 + } 1398 + 1399 + update_mask = 0; 1400 + if (attr_mask & IB_SRQ_LIMIT) { 1401 + attr_mask &= ~IB_SRQ_LIMIT; 1402 + update_mask |= 1403 + EHCA_BMASK_SET(MQPCB_MASK_CURR_SRQ_LIMIT, 1) 1404 + | EHCA_BMASK_SET(MQPCB_MASK_QP_AFF_ASYN_EV_LOG_REG, 1); 1405 + mqpcb->curr_srq_limit = 1406 + EHCA_BMASK_SET(MQPCB_CURR_SRQ_LIMIT, attr->srq_limit); 1407 + mqpcb->qp_aff_asyn_ev_log_reg = 1408 + EHCA_BMASK_SET(QPX_AAELOG_RESET_SRQ_LIMIT, 1); 1409 + } 1410 + 1411 + /* by now, all bits in attr_mask should have been cleared */ 1412 + if (attr_mask) { 1413 + ehca_err(ibsrq->device, "invalid attribute mask bits set " 1414 + "attr_mask=%x", attr_mask); 1415 + ret = -EINVAL; 1416 + goto modify_srq_exit0; 1417 + } 1418 + 1419 + if (ehca_debug_level) 1420 + ehca_dmp(mqpcb, 4*70, "qp_num=%x", my_qp->real_qp_num); 1421 + 1422 + h_ret = hipz_h_modify_qp(shca->ipz_hca_handle, my_qp->ipz_qp_handle, 1423 + NULL, update_mask, mqpcb, 1424 + my_qp->galpas.kernel); 1425 + 1426 + if (h_ret != H_SUCCESS) { 1427 + ret = ehca2ib_return_code(h_ret); 1428 + ehca_err(ibsrq->device, "hipz_h_modify_qp() failed rc=%lx " 1429 + "ehca_qp=%p qp_num=%x", 1430 + h_ret, my_qp, my_qp->real_qp_num); 1431 + } 1432 + 1433 + modify_srq_exit0: 1434 + ehca_free_fw_ctrlblock(mqpcb); 1435 + 1436 + return ret; 1437 + } 1438 + 1439 + int ehca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr) 1440 + { 1441 + struct ehca_qp *my_qp = container_of(srq, struct ehca_qp, ib_srq); 1442 + struct ehca_pd *my_pd = container_of(srq->pd, struct ehca_pd, ib_pd); 1443 + struct ehca_shca *shca = container_of(srq->device, struct ehca_shca, 1556 1444 ib_device); 1445 + struct ipz_adapter_handle adapter_handle = shca->ipz_hca_handle; 1446 + struct hcp_modify_qp_control_block *qpcb; 1447 + u32 cur_pid = current->tgid; 1448 + int ret = 0; 1449 + u64 h_ret; 1450 + 1451 + if (my_pd->ib_pd.uobject && my_pd->ib_pd.uobject->context && 1452 + my_pd->ownpid != cur_pid) { 1453 + ehca_err(srq->device, "Invalid caller pid=%x ownpid=%x", 1454 + cur_pid, my_pd->ownpid); 1455 + return -EINVAL; 1456 + } 1457 + 1458 + qpcb = ehca_alloc_fw_ctrlblock(GFP_KERNEL); 1459 + if (!qpcb) { 1460 + ehca_err(srq->device, "Out of memory for qpcb " 1461 + "ehca_qp=%p qp_num=%x", my_qp, my_qp->real_qp_num); 1462 + return -ENOMEM; 1463 + } 1464 + 1465 + h_ret = hipz_h_query_qp(adapter_handle, my_qp->ipz_qp_handle, 1466 + NULL, qpcb, my_qp->galpas.kernel); 1467 + 1468 + if (h_ret != H_SUCCESS) { 1469 + ret = ehca2ib_return_code(h_ret); 1470 + ehca_err(srq->device, "hipz_h_query_qp() failed " 1471 + "ehca_qp=%p qp_num=%x h_ret=%lx", 1472 + my_qp, my_qp->real_qp_num, h_ret); 1473 + goto query_srq_exit1; 1474 + } 1475 + 1476 + srq_attr->max_wr = qpcb->max_nr_outst_recv_wr - 1; 1477 + srq_attr->srq_limit = EHCA_BMASK_GET( 1478 + MQPCB_CURR_SRQ_LIMIT, qpcb->curr_srq_limit); 1479 + 1480 + if (ehca_debug_level) 1481 + ehca_dmp(qpcb, 4*70, "qp_num=%x", my_qp->real_qp_num); 1482 + 1483 + query_srq_exit1: 1484 + ehca_free_fw_ctrlblock(qpcb); 1485 + 1486 + return ret; 1487 + } 1488 + 1489 + int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp, 1490 + struct ib_uobject *uobject) 1491 + { 1492 + struct ehca_shca *shca = container_of(dev, struct ehca_shca, ib_device); 1557 1493 struct ehca_pd *my_pd = container_of(my_qp->ib_qp.pd, struct ehca_pd, 1558 1494 ib_pd); 1559 1495 u32 cur_pid = current->tgid; 1560 - u32 qp_num = ibqp->qp_num; 1496 + u32 qp_num = my_qp->real_qp_num; 1561 1497 int ret; 1562 1498 u64 h_ret; 1563 1499 u8 port_num; 1564 1500 enum ib_qp_type qp_type; 1565 1501 unsigned long flags; 1566 1502 1567 - if (ibqp->uobject) { 1503 + if (uobject) { 1568 1504 if (my_qp->mm_count_galpa || 1569 1505 my_qp->mm_count_rqueue || my_qp->mm_count_squeue) { 1570 - ehca_err(ibqp->device, "Resources still referenced in " 1571 - "user space qp_num=%x", ibqp->qp_num); 1506 + ehca_err(dev, "Resources still referenced in " 1507 + "user space qp_num=%x", qp_num); 1572 1508 return -EINVAL; 1573 1509 } 1574 1510 if (my_pd->ownpid != cur_pid) { 1575 - ehca_err(ibqp->device, "Invalid caller pid=%x ownpid=%x", 1511 + ehca_err(dev, "Invalid caller pid=%x ownpid=%x", 1576 1512 cur_pid, my_pd->ownpid); 1577 1513 return -EINVAL; 1578 1514 } 1579 1515 } 1580 1516 1581 1517 if (my_qp->send_cq) { 1582 - ret = ehca_cq_unassign_qp(my_qp->send_cq, 1583 - my_qp->real_qp_num); 1518 + ret = ehca_cq_unassign_qp(my_qp->send_cq, qp_num); 1584 1519 if (ret) { 1585 - ehca_err(ibqp->device, "Couldn't unassign qp from " 1520 + ehca_err(dev, "Couldn't unassign qp from " 1586 1521 "send_cq ret=%x qp_num=%x cq_num=%x", ret, 1587 - my_qp->ib_qp.qp_num, my_qp->send_cq->cq_number); 1522 + qp_num, my_qp->send_cq->cq_number); 1588 1523 return ret; 1589 1524 } 1590 1525 } 1591 1526 1592 - spin_lock_irqsave(&ehca_qp_idr_lock, flags); 1527 + write_lock_irqsave(&ehca_qp_idr_lock, flags); 1593 1528 idr_remove(&ehca_qp_idr, my_qp->token); 1594 - spin_unlock_irqrestore(&ehca_qp_idr_lock, flags); 1529 + write_unlock_irqrestore(&ehca_qp_idr_lock, flags); 1595 1530 1596 1531 h_ret = hipz_h_destroy_qp(shca->ipz_hca_handle, my_qp); 1597 1532 if (h_ret != H_SUCCESS) { 1598 - ehca_err(ibqp->device, "hipz_h_destroy_qp() failed rc=%lx " 1533 + ehca_err(dev, "hipz_h_destroy_qp() failed rc=%lx " 1599 1534 "ehca_qp=%p qp_num=%x", h_ret, my_qp, qp_num); 1600 1535 return ehca2ib_return_code(h_ret); 1601 1536 } ··· 1723 1424 /* no support for IB_QPT_SMI yet */ 1724 1425 if (qp_type == IB_QPT_GSI) { 1725 1426 struct ib_event event; 1726 - ehca_info(ibqp->device, "device %s: port %x is inactive.", 1427 + ehca_info(dev, "device %s: port %x is inactive.", 1727 1428 shca->ib_device.name, port_num); 1728 1429 event.device = &shca->ib_device; 1729 1430 event.event = IB_EVENT_PORT_ERR; ··· 1732 1433 ib_dispatch_event(&event); 1733 1434 } 1734 1435 1735 - ipz_queue_dtor(&my_qp->ipz_rqueue); 1736 - ipz_queue_dtor(&my_qp->ipz_squeue); 1436 + if (HAS_RQ(my_qp)) 1437 + ipz_queue_dtor(&my_qp->ipz_rqueue); 1438 + if (HAS_SQ(my_qp)) 1439 + ipz_queue_dtor(&my_qp->ipz_squeue); 1737 1440 kmem_cache_free(qp_cache, my_qp); 1738 1441 return 0; 1442 + } 1443 + 1444 + int ehca_destroy_qp(struct ib_qp *qp) 1445 + { 1446 + return internal_destroy_qp(qp->device, 1447 + container_of(qp, struct ehca_qp, ib_qp), 1448 + qp->uobject); 1449 + } 1450 + 1451 + int ehca_destroy_srq(struct ib_srq *srq) 1452 + { 1453 + return internal_destroy_qp(srq->device, 1454 + container_of(srq, struct ehca_qp, ib_srq), 1455 + srq->uobject); 1739 1456 } 1740 1457 1741 1458 int ehca_init_qp_cache(void)
+56 -29
drivers/infiniband/hw/ehca/ehca_reqs.c
··· 3 3 * 4 4 * post_send/recv, poll_cq, req_notify 5 5 * 6 - * Authors: Waleri Fomin <fomin@de.ibm.com> 7 - * Hoang-Nam Nguyen <hnguyen@de.ibm.com> 6 + * Authors: Hoang-Nam Nguyen <hnguyen@de.ibm.com> 7 + * Waleri Fomin <fomin@de.ibm.com> 8 + * Joachim Fenkes <fenkes@de.ibm.com> 8 9 * Reinhard Ernst <rernst@de.ibm.com> 9 10 * 10 11 * Copyright (c) 2005 IBM Corporation ··· 363 362 struct ehca_wqe *wqe_p; 364 363 int wqe_cnt = 0; 365 364 int ret = 0; 366 - unsigned long spl_flags; 365 + unsigned long flags; 367 366 368 367 /* LOCK the QUEUE */ 369 - spin_lock_irqsave(&my_qp->spinlock_s, spl_flags); 368 + spin_lock_irqsave(&my_qp->spinlock_s, flags); 370 369 371 370 /* loop processes list of send reqs */ 372 371 for (cur_send_wr = send_wr; cur_send_wr != NULL; ··· 407 406 } /* eof for cur_send_wr */ 408 407 409 408 post_send_exit0: 410 - /* UNLOCK the QUEUE */ 411 - spin_unlock_irqrestore(&my_qp->spinlock_s, spl_flags); 412 409 iosync(); /* serialize GAL register access */ 413 410 hipz_update_sqa(my_qp, wqe_cnt); 411 + spin_unlock_irqrestore(&my_qp->spinlock_s, flags); 414 412 return ret; 415 413 } 416 414 417 - int ehca_post_recv(struct ib_qp *qp, 418 - struct ib_recv_wr *recv_wr, 419 - struct ib_recv_wr **bad_recv_wr) 415 + static int internal_post_recv(struct ehca_qp *my_qp, 416 + struct ib_device *dev, 417 + struct ib_recv_wr *recv_wr, 418 + struct ib_recv_wr **bad_recv_wr) 420 419 { 421 - struct ehca_qp *my_qp = container_of(qp, struct ehca_qp, ib_qp); 422 420 struct ib_recv_wr *cur_recv_wr; 423 421 struct ehca_wqe *wqe_p; 424 422 int wqe_cnt = 0; 425 423 int ret = 0; 426 - unsigned long spl_flags; 424 + unsigned long flags; 425 + 426 + if (unlikely(!HAS_RQ(my_qp))) { 427 + ehca_err(dev, "QP has no RQ ehca_qp=%p qp_num=%x ext_type=%d", 428 + my_qp, my_qp->real_qp_num, my_qp->ext_type); 429 + return -ENODEV; 430 + } 427 431 428 432 /* LOCK the QUEUE */ 429 - spin_lock_irqsave(&my_qp->spinlock_r, spl_flags); 433 + spin_lock_irqsave(&my_qp->spinlock_r, flags); 430 434 431 435 /* loop processes list of send reqs */ 432 436 for (cur_recv_wr = recv_wr; cur_recv_wr != NULL; ··· 445 439 *bad_recv_wr = cur_recv_wr; 446 440 if (wqe_cnt == 0) { 447 441 ret = -ENOMEM; 448 - ehca_err(qp->device, "Too many posted WQEs " 449 - "qp_num=%x", qp->qp_num); 442 + ehca_err(dev, "Too many posted WQEs " 443 + "qp_num=%x", my_qp->real_qp_num); 450 444 } 451 445 goto post_recv_exit0; 452 446 } ··· 461 455 *bad_recv_wr = cur_recv_wr; 462 456 if (wqe_cnt == 0) { 463 457 ret = -EINVAL; 464 - ehca_err(qp->device, "Could not write WQE " 465 - "qp_num=%x", qp->qp_num); 458 + ehca_err(dev, "Could not write WQE " 459 + "qp_num=%x", my_qp->real_qp_num); 466 460 } 467 461 goto post_recv_exit0; 468 462 } 469 463 wqe_cnt++; 470 - ehca_gen_dbg("ehca_qp=%p qp_num=%x wqe_cnt=%d", 471 - my_qp, qp->qp_num, wqe_cnt); 464 + ehca_dbg(dev, "ehca_qp=%p qp_num=%x wqe_cnt=%d", 465 + my_qp, my_qp->real_qp_num, wqe_cnt); 472 466 } /* eof for cur_recv_wr */ 473 467 474 468 post_recv_exit0: 475 - spin_unlock_irqrestore(&my_qp->spinlock_r, spl_flags); 476 469 iosync(); /* serialize GAL register access */ 477 470 hipz_update_rqa(my_qp, wqe_cnt); 471 + spin_unlock_irqrestore(&my_qp->spinlock_r, flags); 478 472 return ret; 473 + } 474 + 475 + int ehca_post_recv(struct ib_qp *qp, 476 + struct ib_recv_wr *recv_wr, 477 + struct ib_recv_wr **bad_recv_wr) 478 + { 479 + return internal_post_recv(container_of(qp, struct ehca_qp, ib_qp), 480 + qp->device, recv_wr, bad_recv_wr); 481 + } 482 + 483 + int ehca_post_srq_recv(struct ib_srq *srq, 484 + struct ib_recv_wr *recv_wr, 485 + struct ib_recv_wr **bad_recv_wr) 486 + { 487 + return internal_post_recv(container_of(srq, struct ehca_qp, ib_srq), 488 + srq->device, recv_wr, bad_recv_wr); 479 489 } 480 490 481 491 /* ··· 516 494 int ret = 0; 517 495 struct ehca_cq *my_cq = container_of(cq, struct ehca_cq, ib_cq); 518 496 struct ehca_cqe *cqe; 497 + struct ehca_qp *my_qp; 519 498 int cqe_count = 0; 520 499 521 500 poll_cq_one_read_cqe: ··· 536 513 if (unlikely(cqe->status & WC_STATUS_PURGE_BIT)) { 537 514 struct ehca_qp *qp=ehca_cq_get_qp(my_cq, cqe->local_qp_number); 538 515 int purgeflag; 539 - unsigned long spl_flags; 516 + unsigned long flags; 540 517 if (!qp) { 541 518 ehca_err(cq->device, "cq_num=%x qp_num=%x " 542 519 "could not find qp -> ignore cqe", ··· 546 523 /* ignore this purged cqe */ 547 524 goto poll_cq_one_read_cqe; 548 525 } 549 - spin_lock_irqsave(&qp->spinlock_s, spl_flags); 526 + spin_lock_irqsave(&qp->spinlock_s, flags); 550 527 purgeflag = qp->sqerr_purgeflag; 551 - spin_unlock_irqrestore(&qp->spinlock_s, spl_flags); 528 + spin_unlock_irqrestore(&qp->spinlock_s, flags); 552 529 553 530 if (purgeflag) { 554 531 ehca_dbg(cq->device, "Got CQE with purged bit qp_num=%x " ··· 568 545 } 569 546 570 547 /* tracing cqe */ 571 - if (ehca_debug_level) { 548 + if (unlikely(ehca_debug_level)) { 572 549 ehca_dbg(cq->device, 573 550 "Received COMPLETION ehca_cq=%p cq_num=%x -----", 574 551 my_cq, my_cq->cq_number); ··· 602 579 } else 603 580 wc->status = IB_WC_SUCCESS; 604 581 605 - wc->qp = NULL; 582 + read_lock(&ehca_qp_idr_lock); 583 + my_qp = idr_find(&ehca_qp_idr, cqe->qp_token); 584 + wc->qp = &my_qp->ib_qp; 585 + read_unlock(&ehca_qp_idr_lock); 586 + 606 587 wc->byte_len = cqe->nr_bytes_transferred; 607 588 wc->pkey_index = cqe->pkey_index; 608 589 wc->slid = cqe->rlid; ··· 616 589 wc->imm_data = cpu_to_be32(cqe->immediate_data); 617 590 wc->sl = cqe->service_level; 618 591 619 - if (wc->status != IB_WC_SUCCESS) 592 + if (unlikely(wc->status != IB_WC_SUCCESS)) 620 593 ehca_dbg(cq->device, 621 594 "ehca_cq=%p cq_num=%x WARNING unsuccessful cqe " 622 595 "OPType=%x status=%x qp_num=%x src_qp=%x wr_id=%lx " ··· 637 610 int nr; 638 611 struct ib_wc *current_wc = wc; 639 612 int ret = 0; 640 - unsigned long spl_flags; 613 + unsigned long flags; 641 614 642 615 if (num_entries < 1) { 643 616 ehca_err(cq->device, "Invalid num_entries=%d ehca_cq=%p " ··· 646 619 goto poll_cq_exit0; 647 620 } 648 621 649 - spin_lock_irqsave(&my_cq->spinlock, spl_flags); 622 + spin_lock_irqsave(&my_cq->spinlock, flags); 650 623 for (nr = 0; nr < num_entries; nr++) { 651 624 ret = ehca_poll_cq_one(cq, current_wc); 652 625 if (ret) 653 626 break; 654 627 current_wc++; 655 628 } /* eof for nr */ 656 - spin_unlock_irqrestore(&my_cq->spinlock, spl_flags); 629 + spin_unlock_irqrestore(&my_cq->spinlock, flags); 657 630 if (ret == -EAGAIN || !ret) 658 631 ret = nr; 659 632 ··· 664 637 int ehca_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags notify_flags) 665 638 { 666 639 struct ehca_cq *my_cq = container_of(cq, struct ehca_cq, ib_cq); 667 - unsigned long spl_flags; 668 640 int ret = 0; 669 641 670 642 switch (notify_flags & IB_CQ_SOLICITED_MASK) { ··· 678 652 } 679 653 680 654 if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) { 655 + unsigned long spl_flags; 681 656 spin_lock_irqsave(&my_cq->spinlock, spl_flags); 682 657 ret = ipz_qeit_is_valid(&my_cq->ipz_queue); 683 658 spin_unlock_irqrestore(&my_cq->spinlock, spl_flags);
+1
drivers/infiniband/hw/ehca/ehca_tools.h
··· 59 59 #include <linux/cpu.h> 60 60 #include <linux/device.h> 61 61 62 + #include <asm/atomic.h> 62 63 #include <asm/abs_addr.h> 63 64 #include <asm/ibmebus.h> 64 65 #include <asm/io.h>
+7 -6
drivers/infiniband/hw/ehca/ehca_uverbs.c
··· 253 253 u32 rsrc_type = (fileoffset >> 24) & 0xF; /* sq,rq,cmnd_window */ 254 254 u32 cur_pid = current->tgid; 255 255 u32 ret; 256 - unsigned long flags; 257 256 struct ehca_cq *cq; 258 257 struct ehca_qp *qp; 259 258 struct ehca_pd *pd; 259 + struct ib_uobject *uobject; 260 260 261 261 switch (q_type) { 262 262 case 1: /* CQ */ 263 - spin_lock_irqsave(&ehca_cq_idr_lock, flags); 263 + read_lock(&ehca_cq_idr_lock); 264 264 cq = idr_find(&ehca_cq_idr, idr_handle); 265 - spin_unlock_irqrestore(&ehca_cq_idr_lock, flags); 265 + read_unlock(&ehca_cq_idr_lock); 266 266 267 267 /* make sure this mmap really belongs to the authorized user */ 268 268 if (!cq) ··· 288 288 break; 289 289 290 290 case 2: /* QP */ 291 - spin_lock_irqsave(&ehca_qp_idr_lock, flags); 291 + read_lock(&ehca_qp_idr_lock); 292 292 qp = idr_find(&ehca_qp_idr, idr_handle); 293 - spin_unlock_irqrestore(&ehca_qp_idr_lock, flags); 293 + read_unlock(&ehca_qp_idr_lock); 294 294 295 295 /* make sure this mmap really belongs to the authorized user */ 296 296 if (!qp) ··· 304 304 return -ENOMEM; 305 305 } 306 306 307 - if (!qp->ib_qp.uobject || qp->ib_qp.uobject->context != context) 307 + uobject = IS_SRQ(qp) ? qp->ib_srq.uobject : qp->ib_qp.uobject; 308 + if (!uobject || uobject->context != context) 308 309 return -EINVAL; 309 310 310 311 ret = ehca_mmap_qp(vma, qp, rsrc_type);
+31 -27
drivers/infiniband/hw/ehca/hcp_if.c
··· 5 5 * 6 6 * Authors: Christoph Raisch <raisch@de.ibm.com> 7 7 * Hoang-Nam Nguyen <hnguyen@de.ibm.com> 8 + * Joachim Fenkes <fenkes@de.ibm.com> 8 9 * Gerd Bayer <gerd.bayer@de.ibm.com> 9 10 * Waleri Fomin <fomin@de.ibm.com> 10 11 * ··· 63 62 #define H_ALL_RES_QP_MAX_SEND_SGE EHCA_BMASK_IBM(32, 39) 64 63 #define H_ALL_RES_QP_MAX_RECV_SGE EHCA_BMASK_IBM(40, 47) 65 64 65 + #define H_ALL_RES_QP_UD_AV_LKEY EHCA_BMASK_IBM(32, 63) 66 + #define H_ALL_RES_QP_SRQ_QP_TOKEN EHCA_BMASK_IBM(0, 31) 67 + #define H_ALL_RES_QP_SRQ_QP_HANDLE EHCA_BMASK_IBM(0, 64) 68 + #define H_ALL_RES_QP_SRQ_LIMIT EHCA_BMASK_IBM(48, 63) 69 + #define H_ALL_RES_QP_SRQ_QPN EHCA_BMASK_IBM(40, 63) 70 + 66 71 #define H_ALL_RES_QP_ACT_OUTST_SEND_WR EHCA_BMASK_IBM(16, 31) 67 72 #define H_ALL_RES_QP_ACT_OUTST_RECV_WR EHCA_BMASK_IBM(48, 63) 68 73 #define H_ALL_RES_QP_ACT_SEND_SGE EHCA_BMASK_IBM(8, 15) ··· 81 74 #define H_MP_SHUTDOWN EHCA_BMASK_IBM(48, 48) 82 75 #define H_MP_RESET_QKEY_CTR EHCA_BMASK_IBM(49, 49) 83 76 84 - /* direct access qp controls */ 85 - #define DAQP_CTRL_ENABLE 0x01 86 - #define DAQP_CTRL_SEND_COMP 0x20 87 - #define DAQP_CTRL_RECV_COMP 0x40 77 + static DEFINE_SPINLOCK(hcall_lock); 88 78 89 79 static u32 get_longbusy_msecs(int longbusy_rc) 90 80 { ··· 159 155 { 160 156 long ret; 161 157 int i, sleep_msecs, lock_is_set = 0; 162 - unsigned long flags; 158 + unsigned long flags = 0; 163 159 164 160 ehca_gen_dbg("opcode=%lx arg1=%lx arg2=%lx arg3=%lx arg4=%lx " 165 161 "arg5=%lx arg6=%lx arg7=%lx arg8=%lx arg9=%lx", ··· 288 284 } 289 285 290 286 u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle, 291 - struct ehca_qp *qp, 292 287 struct ehca_alloc_qp_parms *parms) 293 288 { 294 289 u64 ret; 295 - u64 allocate_controls; 296 - u64 max_r10_reg; 290 + u64 allocate_controls, max_r10_reg, r11, r12; 297 291 u64 outs[PLPAR_HCALL9_BUFSIZE]; 298 - u16 max_nr_receive_wqes = qp->init_attr.cap.max_recv_wr + 1; 299 - u16 max_nr_send_wqes = qp->init_attr.cap.max_send_wr + 1; 300 - int daqp_ctrl = parms->daqp_ctrl; 301 292 302 293 allocate_controls = 303 - EHCA_BMASK_SET(H_ALL_RES_QP_ENHANCED_OPS, 304 - (daqp_ctrl & DAQP_CTRL_ENABLE) ? 1 : 0) 294 + EHCA_BMASK_SET(H_ALL_RES_QP_ENHANCED_OPS, parms->ext_type) 305 295 | EHCA_BMASK_SET(H_ALL_RES_QP_PTE_PIN, 0) 306 296 | EHCA_BMASK_SET(H_ALL_RES_QP_SERVICE_TYPE, parms->servicetype) 307 297 | EHCA_BMASK_SET(H_ALL_RES_QP_SIGNALING_TYPE, parms->sigtype) 308 298 | EHCA_BMASK_SET(H_ALL_RES_QP_LL_RQ_CQE_POSTING, 309 - (daqp_ctrl & DAQP_CTRL_RECV_COMP) ? 1 : 0) 299 + !!(parms->ll_comp_flags & LLQP_RECV_COMP)) 310 300 | EHCA_BMASK_SET(H_ALL_RES_QP_LL_SQ_CQE_POSTING, 311 - (daqp_ctrl & DAQP_CTRL_SEND_COMP) ? 1 : 0) 301 + !!(parms->ll_comp_flags & LLQP_SEND_COMP)) 312 302 | EHCA_BMASK_SET(H_ALL_RES_QP_UD_AV_LKEY_CTRL, 313 303 parms->ud_av_l_key_ctl) 314 304 | EHCA_BMASK_SET(H_ALL_RES_QP_RESOURCE_TYPE, 1); 315 305 316 306 max_r10_reg = 317 307 EHCA_BMASK_SET(H_ALL_RES_QP_MAX_OUTST_SEND_WR, 318 - max_nr_send_wqes) 308 + parms->max_send_wr + 1) 319 309 | EHCA_BMASK_SET(H_ALL_RES_QP_MAX_OUTST_RECV_WR, 320 - max_nr_receive_wqes) 310 + parms->max_recv_wr + 1) 321 311 | EHCA_BMASK_SET(H_ALL_RES_QP_MAX_SEND_SGE, 322 312 parms->max_send_sge) 323 313 | EHCA_BMASK_SET(H_ALL_RES_QP_MAX_RECV_SGE, 324 314 parms->max_recv_sge); 325 315 316 + r11 = EHCA_BMASK_SET(H_ALL_RES_QP_SRQ_QP_TOKEN, parms->srq_token); 317 + 318 + if (parms->ext_type == EQPT_SRQ) 319 + r12 = EHCA_BMASK_SET(H_ALL_RES_QP_SRQ_LIMIT, parms->srq_limit); 320 + else 321 + r12 = EHCA_BMASK_SET(H_ALL_RES_QP_SRQ_QPN, parms->srq_qpn); 322 + 326 323 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs, 327 324 adapter_handle.handle, /* r4 */ 328 325 allocate_controls, /* r5 */ 329 - qp->send_cq->ipz_cq_handle.handle, 330 - qp->recv_cq->ipz_cq_handle.handle, 331 - parms->ipz_eq_handle.handle, 332 - ((u64)qp->token << 32) | parms->pd.value, 333 - max_r10_reg, /* r10 */ 334 - parms->ud_av_l_key_ctl, /* r11 */ 335 - 0); 336 - qp->ipz_qp_handle.handle = outs[0]; 337 - qp->real_qp_num = (u32)outs[1]; 326 + parms->send_cq_handle.handle, 327 + parms->recv_cq_handle.handle, 328 + parms->eq_handle.handle, 329 + ((u64)parms->token << 32) | parms->pd.value, 330 + max_r10_reg, r11, r12); 331 + 332 + parms->qp_handle.handle = outs[0]; 333 + parms->real_qp_num = (u32)outs[1]; 338 334 parms->act_nr_send_wqes = 339 335 (u16)EHCA_BMASK_GET(H_ALL_RES_QP_ACT_OUTST_SEND_WR, outs[2]); 340 336 parms->act_nr_recv_wqes = ··· 349 345 (u32)EHCA_BMASK_GET(H_ALL_RES_QP_RQUEUE_SIZE_PAGES, outs[4]); 350 346 351 347 if (ret == H_SUCCESS) 352 - hcp_galpas_ctor(&qp->galpas, outs[6], outs[6]); 348 + hcp_galpas_ctor(&parms->galpas, outs[6], outs[6]); 353 349 354 350 if (ret == H_NOT_ENOUGH_RESOURCES) 355 351 ehca_gen_err("Not enough resources. ret=%lx", ret);
-1
drivers/infiniband/hw/ehca/hcp_if.h
··· 78 78 * initialize resources, create empty QPPTs (2 rings). 79 79 */ 80 80 u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle, 81 - struct ehca_qp *qp, 82 81 struct ehca_alloc_qp_parms *parms); 83 82 84 83 u64 hipz_h_query_port(const struct ipz_adapter_handle adapter_handle,
+19
drivers/infiniband/hw/ehca/hipz_hw.h
··· 163 163 164 164 #define QPX_SQADDER EHCA_BMASK_IBM(48,63) 165 165 #define QPX_RQADDER EHCA_BMASK_IBM(48,63) 166 + #define QPX_AAELOG_RESET_SRQ_LIMIT EHCA_BMASK_IBM(3,3) 166 167 167 168 #define QPTEMM_OFFSET(x) offsetof(struct hipz_qptemm,x) 168 169 ··· 360 359 u32 max_isns_eq; 361 360 u32 max_neq; 362 361 } __attribute__ ((packed)); 362 + 363 + #define HCA_CAP_AH_PORT_NR_CHECK EHCA_BMASK_IBM( 0, 0) 364 + #define HCA_CAP_ATOMIC EHCA_BMASK_IBM( 1, 1) 365 + #define HCA_CAP_AUTO_PATH_MIG EHCA_BMASK_IBM( 2, 2) 366 + #define HCA_CAP_BAD_P_KEY_CTR EHCA_BMASK_IBM( 3, 3) 367 + #define HCA_CAP_SQD_RTS_PORT_CHANGE EHCA_BMASK_IBM( 4, 4) 368 + #define HCA_CAP_CUR_QP_STATE_MOD EHCA_BMASK_IBM( 5, 5) 369 + #define HCA_CAP_INIT_TYPE EHCA_BMASK_IBM( 6, 6) 370 + #define HCA_CAP_PORT_ACTIVE_EVENT EHCA_BMASK_IBM( 7, 7) 371 + #define HCA_CAP_Q_KEY_VIOL_CTR EHCA_BMASK_IBM( 8, 8) 372 + #define HCA_CAP_WQE_RESIZE EHCA_BMASK_IBM( 9, 9) 373 + #define HCA_CAP_RAW_PACKET_MCAST EHCA_BMASK_IBM(10, 10) 374 + #define HCA_CAP_SHUTDOWN_PORT EHCA_BMASK_IBM(11, 11) 375 + #define HCA_CAP_RC_LL_QP EHCA_BMASK_IBM(12, 12) 376 + #define HCA_CAP_SRQ EHCA_BMASK_IBM(13, 13) 377 + #define HCA_CAP_UD_LL_QP EHCA_BMASK_IBM(16, 16) 378 + #define HCA_CAP_RESIZE_MR EHCA_BMASK_IBM(17, 17) 379 + #define HCA_CAP_MINI_QP EHCA_BMASK_IBM(18, 18) 363 380 364 381 /* query port response block */ 365 382 struct hipz_query_port {
+10 -18
drivers/infiniband/hw/ehca/ipz_pt_fn.h
··· 105 105 * step in struct ipz_queue, will wrap in ringbuffer 106 106 * returns address (kv) of Queue Entry BEFORE increment 107 107 * warning don't use in parallel with ipz_qpageit_get_inc() 108 - * warning unpredictable results may occur if steps>act_nr_of_queue_entries 109 108 */ 110 109 static inline void *ipz_qeit_get_inc(struct ipz_queue *queue) 111 110 { ··· 120 121 } 121 122 122 123 /* 124 + * return a bool indicating whether current Queue Entry is valid 125 + */ 126 + static inline int ipz_qeit_is_valid(struct ipz_queue *queue) 127 + { 128 + struct ehca_cqe *cqe = ipz_qeit_get(queue); 129 + return ((cqe->cqe_flags >> 7) == (queue->toggle_state & 1)); 130 + } 131 + 132 + /* 123 133 * return current Queue Entry, increment Queue Entry iterator by one 124 134 * step in struct ipz_queue, will wrap in ringbuffer 125 135 * returns address (kv) of Queue Entry BEFORE increment 126 136 * returns 0 and does not increment, if wrong valid state 127 137 * warning don't use in parallel with ipz_qpageit_get_inc() 128 - * warning unpredictable results may occur if steps>act_nr_of_queue_entries 129 138 */ 130 139 static inline void *ipz_qeit_get_inc_valid(struct ipz_queue *queue) 131 140 { 132 - struct ehca_cqe *cqe = ipz_qeit_get(queue); 133 - u32 cqe_flags = cqe->cqe_flags; 134 - 135 - if ((cqe_flags >> 7) != (queue->toggle_state & 1)) 136 - return NULL; 137 - 138 - ipz_qeit_get_inc(queue); 139 - return cqe; 140 - } 141 - 142 - static inline int ipz_qeit_is_valid(struct ipz_queue *queue) 143 - { 144 - struct ehca_cqe *cqe = ipz_qeit_get(queue); 145 - u32 cqe_flags = cqe->cqe_flags; 146 - 147 - return cqe_flags >> 7 == (queue->toggle_state & 1); 141 + return ipz_qeit_is_valid(queue) ? ipz_qeit_get_inc(queue) : NULL; 148 142 } 149 143 150 144 /*
+1 -1
drivers/infiniband/hw/ipath/Kconfig
··· 1 1 config INFINIBAND_IPATH 2 2 tristate "QLogic InfiniPath Driver" 3 - depends on (PCI_MSI || HT_IRQ) && 64BIT && INFINIBAND && NET 3 + depends on (PCI_MSI || HT_IRQ) && 64BIT && NET 4 4 ---help--- 5 5 This is a driver for QLogic InfiniPath host channel adapters, 6 6 including InfiniBand verbs support. This driver allows these
+29 -4
drivers/infiniband/hw/ipath/ipath_common.h
··· 189 189 #define IPATH_RUNTIME_FORCE_WC_ORDER 0x4 190 190 #define IPATH_RUNTIME_RCVHDR_COPY 0x8 191 191 #define IPATH_RUNTIME_MASTER 0x10 192 - #define IPATH_RUNTIME_PBC_REWRITE 0x20 193 - #define IPATH_RUNTIME_LOOSE_DMA_ALIGN 0x40 192 + /* 0x20 and 0x40 are no longer used, but are reserved for ABI compatibility */ 194 193 195 194 /* 196 195 * This structure is returned by ipath_userinit() immediately after ··· 431 432 #define IPATH_CMD_UNUSED_1 25 432 433 #define IPATH_CMD_UNUSED_2 26 433 434 #define IPATH_CMD_PIOAVAILUPD 27 /* force an update of PIOAvail reg */ 435 + #define IPATH_CMD_POLL_TYPE 28 /* set the kind of polling we want */ 434 436 435 - #define IPATH_CMD_MAX 27 437 + #define IPATH_CMD_MAX 28 438 + 439 + /* 440 + * Poll types 441 + */ 442 + #define IPATH_POLL_TYPE_URGENT 0x01 443 + #define IPATH_POLL_TYPE_OVERFLOW 0x02 436 444 437 445 struct ipath_port_info { 438 446 __u32 num_active; /* number of active units */ ··· 480 474 __u16 part_key; 481 475 /* user address of __u32 bitmask of active slaves */ 482 476 __u64 slave_mask_addr; 477 + /* type of polling we want */ 478 + __u16 poll_type; 483 479 } cmd; 484 480 }; 485 481 ··· 510 502 struct ipath_iovec sps_iov[4]; 511 503 }; 512 504 513 - /* Passed into diag data special file's ->write method. */ 505 + /* 506 + * diagnostics can send a packet by "writing" one of the following 507 + * two structs to diag data special file 508 + * The first is the legacy version for backward compatibility 509 + */ 514 510 struct ipath_diag_pkt { 515 511 __u32 unit; 516 512 __u64 data; 513 + __u32 len; 514 + }; 515 + 516 + /* The second diag_pkt struct is the expanded version that allows 517 + * more control over the packet, specifically, by allowing a custom 518 + * pbc (+ extra) qword, so that special modes and deliberate 519 + * changes to CRCs can be used. The elements were also re-ordered 520 + * for better alignment and to avoid padding issues. 521 + */ 522 + struct ipath_diag_xpkt { 523 + __u64 data; 524 + __u64 pbc_wd; 525 + __u32 unit; 517 526 __u32 len; 518 527 }; 519 528
+5 -2
drivers/infiniband/hw/ipath/ipath_cq.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 90 90 wc->queue[head].sl = entry->sl; 91 91 wc->queue[head].dlid_path_bits = entry->dlid_path_bits; 92 92 wc->queue[head].port_num = entry->port_num; 93 + /* Make sure queue entry is written before the head index. */ 94 + smp_wmb(); 93 95 wc->head = next; 94 96 95 97 if (cq->notify == IB_CQ_NEXT_COMP || ··· 141 139 142 140 if (tail == wc->head) 143 141 break; 144 - 142 + /* Make sure entry is read after head index is read. */ 143 + smp_rmb(); 145 144 qp = ipath_lookup_qpn(&to_idev(cq->ibcq.device)->qp_table, 146 145 wc->queue[tail].qp_num); 147 146 entry->qp = &qp->ibqp;
+1 -1
drivers/infiniband/hw/ipath/ipath_debug.h
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+35 -6
drivers/infiniband/hw/ipath/ipath_diag.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 323 323 { 324 324 u32 __iomem *piobuf; 325 325 u32 plen, clen, pbufn; 326 - struct ipath_diag_pkt dp; 326 + struct ipath_diag_pkt odp; 327 + struct ipath_diag_xpkt dp; 327 328 u32 *tmpbuf = NULL; 328 329 struct ipath_devdata *dd; 329 330 ssize_t ret = 0; 330 331 u64 val; 331 332 332 - if (count < sizeof(dp)) { 333 + if (count != sizeof(dp)) { 333 334 ret = -EINVAL; 334 335 goto bail; 335 336 } ··· 338 337 if (copy_from_user(&dp, data, sizeof(dp))) { 339 338 ret = -EFAULT; 340 339 goto bail; 340 + } 341 + 342 + /* 343 + * Due to padding/alignment issues (lessened with new struct) 344 + * the old and new structs are the same length. We need to 345 + * disambiguate them, which we can do because odp.len has never 346 + * been less than the total of LRH+BTH+DETH so far, while 347 + * dp.unit (same offset) unit is unlikely to get that high. 348 + * Similarly, dp.data, the pointer to user at the same offset 349 + * as odp.unit, is almost certainly at least one (512byte)page 350 + * "above" NULL. The if-block below can be omitted if compatibility 351 + * between a new driver and older diagnostic code is unimportant. 352 + * compatibility the other direction (new diags, old driver) is 353 + * handled in the diagnostic code, with a warning. 354 + */ 355 + if (dp.unit >= 20 && dp.data < 512) { 356 + /* very probable version mismatch. Fix it up */ 357 + memcpy(&odp, &dp, sizeof(odp)); 358 + /* We got a legacy dp, copy elements to dp */ 359 + dp.unit = odp.unit; 360 + dp.data = odp.data; 361 + dp.len = odp.len; 362 + dp.pbc_wd = 0; /* Indicate we need to compute PBC wd */ 341 363 } 342 364 343 365 /* send count must be an exact number of dwords */ ··· 395 371 ret = -ENODEV; 396 372 goto bail; 397 373 } 374 + /* Check link state, but not if we have custom PBC */ 398 375 val = dd->ipath_lastibcstat & IPATH_IBSTATE_MASK; 399 - if (val != IPATH_IBSTATE_INIT && val != IPATH_IBSTATE_ARM && 400 - val != IPATH_IBSTATE_ACTIVE) { 376 + if (!dp.pbc_wd && val != IPATH_IBSTATE_INIT && 377 + val != IPATH_IBSTATE_ARM && val != IPATH_IBSTATE_ACTIVE) { 401 378 ipath_cdbg(VERBOSE, "unit %u not ready (state %llx)\n", 402 379 dd->ipath_unit, (unsigned long long) val); 403 380 ret = -EINVAL; ··· 444 419 ipath_cdbg(VERBOSE, "unit %u 0x%x+1w pio%d\n", 445 420 dd->ipath_unit, plen - 1, pbufn); 446 421 422 + if (dp.pbc_wd == 0) 423 + /* Legacy operation, use computed pbc_wd */ 424 + dp.pbc_wd = plen; 425 + 447 426 /* we have to flush after the PBC for correctness on some cpus 448 427 * or WC buffer can be written out of order */ 449 - writeq(plen, piobuf); 428 + writeq(dp.pbc_wd, piobuf); 450 429 ipath_flush_wc(); 451 430 /* copy all by the trigger word, then flush, so it's written 452 431 * to chip before trigger word, then write trigger word, then
+155 -32
drivers/infiniband/hw/ipath/ipath_driver.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 104 104 #define PCI_DEVICE_ID_INFINIPATH_HT 0xd 105 105 #define PCI_DEVICE_ID_INFINIPATH_PE800 0x10 106 106 107 + /* Number of seconds before our card status check... */ 108 + #define STATUS_TIMEOUT 60 109 + 107 110 static const struct pci_device_id ipath_pci_tbl[] = { 108 111 { PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_HT) }, 109 112 { PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_PE800) }, ··· 122 119 .id_table = ipath_pci_tbl, 123 120 }; 124 121 122 + static void ipath_check_status(struct work_struct *work) 123 + { 124 + struct ipath_devdata *dd = container_of(work, struct ipath_devdata, 125 + status_work.work); 126 + 127 + /* 128 + * If we don't have any interrupts, let the user know and 129 + * don't bother checking again. 130 + */ 131 + if (dd->ipath_int_counter == 0) 132 + dev_err(&dd->pcidev->dev, "No interrupts detected.\n"); 133 + } 125 134 126 135 static inline void read_bars(struct ipath_devdata *dd, struct pci_dev *dev, 127 136 u32 *bar0, u32 *bar1) ··· 201 186 202 187 dd->pcidev = pdev; 203 188 pci_set_drvdata(pdev, dd); 189 + 190 + INIT_DELAYED_WORK(&dd->status_work, ipath_check_status); 204 191 205 192 list_add(&dd->ipath_list, &ipath_dev_list); 206 193 ··· 521 504 ipath_diag_add(dd); 522 505 ipath_register_ib_device(dd); 523 506 507 + /* Check that card status in STATUS_TIMEOUT seconds. */ 508 + schedule_delayed_work(&dd->status_work, HZ * STATUS_TIMEOUT); 509 + 524 510 goto bail; 525 511 526 512 bail_irqsetup: ··· 651 631 */ 652 632 ipath_shutdown_device(dd); 653 633 634 + cancel_delayed_work(&dd->status_work); 635 + flush_scheduled_work(); 636 + 654 637 if (dd->verbs_dev) 655 638 ipath_unregister_ib_device(dd->verbs_dev); 656 639 ··· 722 699 u64 sendctrl, sendorig; 723 700 724 701 ipath_cdbg(PKT, "disarm %u PIObufs first=%u\n", cnt, first); 725 - sendorig = dd->ipath_sendctrl | INFINIPATH_S_DISARM; 702 + sendorig = dd->ipath_sendctrl; 726 703 for (i = first; i < last; i++) { 727 - sendctrl = sendorig | 704 + sendctrl = sendorig | INFINIPATH_S_DISARM | 728 705 (i << INFINIPATH_S_DISARMPIOBUF_SHIFT); 729 706 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 730 707 sendctrl); ··· 735 712 * while we were looping; no critical bits that would require 736 713 * locking. 737 714 * 738 - * Write a 0, and then the original value, reading scratch in 715 + * disable PIOAVAILUPD, then re-enable, reading scratch in 739 716 * between. This seems to avoid a chip timing race that causes 740 717 * pioavail updates to memory to stop. 741 718 */ 742 719 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 743 - 0); 720 + sendorig & ~IPATH_S_PIOBUFAVAILUPD); 744 721 sendorig = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 745 722 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 746 723 dd->ipath_sendctrl); ··· 1037 1014 goto bail; 1038 1015 } 1039 1016 1040 - /* There is already a thread processing this queue. */ 1041 - if (test_and_set_bit(0, &dd->ipath_rcv_pending)) 1042 - goto bail; 1043 - 1044 1017 l = dd->ipath_port0head; 1045 1018 hdrqtail = (u32) le64_to_cpu(*dd->ipath_hdrqtailptr); 1046 1019 if (l == hdrqtail) 1047 - goto done; 1020 + goto bail; 1048 1021 1049 1022 reloop: 1050 1023 for (i = 0; l != hdrqtail; i++) { ··· 1174 1155 ipath_stats.sps_port0pkts += pkttot; 1175 1156 ipath_stats.sps_avgpkts_call = 1176 1157 ipath_stats.sps_port0pkts / ++totcalls; 1177 - 1178 - done: 1179 - clear_bit(0, &dd->ipath_rcv_pending); 1180 - smp_mb__after_clear_bit(); 1181 1158 1182 1159 bail:; 1183 1160 } ··· 1604 1589 return ret; 1605 1590 } 1606 1591 1592 + 1593 + /* 1594 + * Flush all sends that might be in the ready to send state, as well as any 1595 + * that are in the process of being sent. Used whenever we need to be 1596 + * sure the send side is idle. Cleans up all buffer state by canceling 1597 + * all pio buffers, and issuing an abort, which cleans up anything in the 1598 + * launch fifo. The cancel is superfluous on some chip versions, but 1599 + * it's safer to always do it. 1600 + * PIOAvail bits are updated by the chip as if normal send had happened. 1601 + */ 1602 + void ipath_cancel_sends(struct ipath_devdata *dd) 1603 + { 1604 + ipath_dbg("Cancelling all in-progress send buffers\n"); 1605 + dd->ipath_lastcancel = jiffies+HZ/2; /* skip armlaunch errs a bit */ 1606 + /* 1607 + * the abort bit is auto-clearing. We read scratch to be sure 1608 + * that cancels and the abort have taken effect in the chip. 1609 + */ 1610 + ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 1611 + INFINIPATH_S_ABORT); 1612 + ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 1613 + ipath_disarm_piobufs(dd, 0, 1614 + (unsigned)(dd->ipath_piobcnt2k + dd->ipath_piobcnt4k)); 1615 + 1616 + /* and again, be sure all have hit the chip */ 1617 + ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 1618 + } 1619 + 1620 + 1607 1621 static void ipath_set_ib_lstate(struct ipath_devdata *dd, int which) 1608 1622 { 1609 1623 static const char *what[4] = { ··· 1654 1610 INFINIPATH_IBCS_LINKTRAININGSTATE_MASK]); 1655 1611 /* flush all queued sends when going to DOWN or INIT, to be sure that 1656 1612 * they don't block MAD packets */ 1657 - if (!linkcmd || linkcmd == INFINIPATH_IBCC_LINKCMD_INIT) { 1658 - ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 1659 - INFINIPATH_S_ABORT); 1660 - ipath_disarm_piobufs(dd, dd->ipath_lastport_piobuf, 1661 - (unsigned)(dd->ipath_piobcnt2k + 1662 - dd->ipath_piobcnt4k) - 1663 - dd->ipath_lastport_piobuf); 1664 - } 1613 + if (!linkcmd || linkcmd == INFINIPATH_IBCC_LINKCMD_INIT) 1614 + ipath_cancel_sends(dd); 1665 1615 1666 1616 ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl, 1667 1617 dd->ipath_ibcctrl | which); ··· 1877 1839 ipath_write_kreg(dd, where, value); 1878 1840 } 1879 1841 1842 + /* 1843 + * Following deal with the "obviously simple" task of overriding the state 1844 + * of the LEDS, which normally indicate link physical and logical status. 1845 + * The complications arise in dealing with different hardware mappings 1846 + * and the board-dependent routine being called from interrupts. 1847 + * and then there's the requirement to _flash_ them. 1848 + */ 1849 + #define LED_OVER_FREQ_SHIFT 8 1850 + #define LED_OVER_FREQ_MASK (0xFF<<LED_OVER_FREQ_SHIFT) 1851 + /* Below is "non-zero" to force override, but both actual LEDs are off */ 1852 + #define LED_OVER_BOTH_OFF (8) 1853 + 1854 + void ipath_run_led_override(unsigned long opaque) 1855 + { 1856 + struct ipath_devdata *dd = (struct ipath_devdata *)opaque; 1857 + int timeoff; 1858 + int pidx; 1859 + u64 lstate, ltstate, val; 1860 + 1861 + if (!(dd->ipath_flags & IPATH_INITTED)) 1862 + return; 1863 + 1864 + pidx = dd->ipath_led_override_phase++ & 1; 1865 + dd->ipath_led_override = dd->ipath_led_override_vals[pidx]; 1866 + timeoff = dd->ipath_led_override_timeoff; 1867 + 1868 + /* 1869 + * below potentially restores the LED values per current status, 1870 + * should also possibly setup the traffic-blink register, 1871 + * but leave that to per-chip functions. 1872 + */ 1873 + val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_ibcstatus); 1874 + ltstate = (val >> INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) & 1875 + INFINIPATH_IBCS_LINKTRAININGSTATE_MASK; 1876 + lstate = (val >> INFINIPATH_IBCS_LINKSTATE_SHIFT) & 1877 + INFINIPATH_IBCS_LINKSTATE_MASK; 1878 + 1879 + dd->ipath_f_setextled(dd, lstate, ltstate); 1880 + mod_timer(&dd->ipath_led_override_timer, jiffies + timeoff); 1881 + } 1882 + 1883 + void ipath_set_led_override(struct ipath_devdata *dd, unsigned int val) 1884 + { 1885 + int timeoff, freq; 1886 + 1887 + if (!(dd->ipath_flags & IPATH_INITTED)) 1888 + return; 1889 + 1890 + /* First check if we are blinking. If not, use 1HZ polling */ 1891 + timeoff = HZ; 1892 + freq = (val & LED_OVER_FREQ_MASK) >> LED_OVER_FREQ_SHIFT; 1893 + 1894 + if (freq) { 1895 + /* For blink, set each phase from one nybble of val */ 1896 + dd->ipath_led_override_vals[0] = val & 0xF; 1897 + dd->ipath_led_override_vals[1] = (val >> 4) & 0xF; 1898 + timeoff = (HZ << 4)/freq; 1899 + } else { 1900 + /* Non-blink set both phases the same. */ 1901 + dd->ipath_led_override_vals[0] = val & 0xF; 1902 + dd->ipath_led_override_vals[1] = val & 0xF; 1903 + } 1904 + dd->ipath_led_override_timeoff = timeoff; 1905 + 1906 + /* 1907 + * If the timer has not already been started, do so. Use a "quick" 1908 + * timeout so the function will be called soon, to look at our request. 1909 + */ 1910 + if (atomic_inc_return(&dd->ipath_led_override_timer_active) == 1) { 1911 + /* Need to start timer */ 1912 + init_timer(&dd->ipath_led_override_timer); 1913 + dd->ipath_led_override_timer.function = 1914 + ipath_run_led_override; 1915 + dd->ipath_led_override_timer.data = (unsigned long) dd; 1916 + dd->ipath_led_override_timer.expires = jiffies + 1; 1917 + add_timer(&dd->ipath_led_override_timer); 1918 + } else { 1919 + atomic_dec(&dd->ipath_led_override_timer_active); 1920 + } 1921 + } 1922 + 1880 1923 /** 1881 1924 * ipath_shutdown_device - shut down a device 1882 1925 * @dd: the infinipath device ··· 1998 1879 */ 1999 1880 udelay(5); 2000 1881 2001 - /* 2002 - * abort any armed or launched PIO buffers that didn't go. (self 2003 - * clearing). Will cause any packet currently being transmitted to 2004 - * go out with an EBP, and may also cause a short packet error on 2005 - * the receiver. 2006 - */ 2007 - ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 2008 - INFINIPATH_S_ABORT); 2009 - 2010 1882 ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_DISABLE << 2011 1883 INFINIPATH_IBCC_LINKINITCMD_SHIFT); 1884 + ipath_cancel_sends(dd); 2012 1885 2013 1886 /* disable IBC */ 2014 1887 dd->ipath_control &= ~INFINIPATH_C_LINKENABLE; ··· 2013 1902 * Turn the LEDs off explictly for the same reason. 2014 1903 */ 2015 1904 dd->ipath_f_quiet_serdes(dd); 2016 - dd->ipath_f_setextled(dd, 0, 0); 2017 1905 2018 1906 if (dd->ipath_stats_timer_active) { 2019 1907 del_timer_sync(&dd->ipath_stats_timer); ··· 2028 1918 ~0ULL & ~INFINIPATH_HWE_MEMBISTFAILED); 2029 1919 ipath_write_kreg(dd, dd->ipath_kregs->kr_errorclear, -1LL); 2030 1920 ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, -1LL); 1921 + 1922 + ipath_cdbg(VERBOSE, "Flush time and errors to EEPROM\n"); 1923 + ipath_update_eeprom_log(dd); 2031 1924 } 2032 1925 2033 1926 /** ··· 2190 2077 ret = -ENODEV; 2191 2078 goto bail; 2192 2079 } 2080 + 2081 + if (atomic_read(&dd->ipath_led_override_timer_active)) { 2082 + /* Need to stop LED timer, _then_ shut off LEDs */ 2083 + del_timer_sync(&dd->ipath_led_override_timer); 2084 + atomic_set(&dd->ipath_led_override_timer_active, 0); 2085 + } 2086 + 2087 + /* Shut off LEDs after we are sure timer is not running */ 2088 + dd->ipath_led_override = LED_OVER_BOTH_OFF; 2089 + dd->ipath_f_setextled(dd, 0, 0); 2193 2090 2194 2091 dev_info(&dd->pcidev->dev, "Reset on unit %u requested\n", unit); 2195 2092
+271 -38
drivers/infiniband/hw/ipath/ipath_eeprom.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 95 95 enum i2c_type line, 96 96 enum i2c_state new_line_state) 97 97 { 98 - u64 read_val, write_val, mask, *gpioval; 98 + u64 out_mask, dir_mask, *gpioval; 99 + unsigned long flags = 0; 99 100 100 101 gpioval = &dd->ipath_gpio_out; 101 - read_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extctrl); 102 - if (line == i2c_line_scl) 103 - mask = dd->ipath_gpio_scl; 104 - else 105 - mask = dd->ipath_gpio_sda; 106 - 107 - if (new_line_state == i2c_line_high) 108 - /* tri-state the output rather than force high */ 109 - write_val = read_val & ~mask; 110 - else 111 - /* config line to be an output */ 112 - write_val = read_val | mask; 113 - ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, write_val); 114 - 115 - /* set high and verify */ 116 - if (new_line_state == i2c_line_high) 117 - write_val = 0x1UL; 118 - else 119 - write_val = 0x0UL; 120 102 121 103 if (line == i2c_line_scl) { 122 - write_val <<= dd->ipath_gpio_scl_num; 123 - *gpioval = *gpioval & ~(1UL << dd->ipath_gpio_scl_num); 124 - *gpioval |= write_val; 104 + dir_mask = dd->ipath_gpio_scl; 105 + out_mask = (1UL << dd->ipath_gpio_scl_num); 125 106 } else { 126 - write_val <<= dd->ipath_gpio_sda_num; 127 - *gpioval = *gpioval & ~(1UL << dd->ipath_gpio_sda_num); 128 - *gpioval |= write_val; 107 + dir_mask = dd->ipath_gpio_sda; 108 + out_mask = (1UL << dd->ipath_gpio_sda_num); 129 109 } 110 + 111 + spin_lock_irqsave(&dd->ipath_gpio_lock, flags); 112 + if (new_line_state == i2c_line_high) { 113 + /* tri-state the output rather than force high */ 114 + dd->ipath_extctrl &= ~dir_mask; 115 + } else { 116 + /* config line to be an output */ 117 + dd->ipath_extctrl |= dir_mask; 118 + } 119 + ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, dd->ipath_extctrl); 120 + 121 + /* set output as well (no real verify) */ 122 + if (new_line_state == i2c_line_high) 123 + *gpioval |= out_mask; 124 + else 125 + *gpioval &= ~out_mask; 126 + 130 127 ipath_write_kreg(dd, dd->ipath_kregs->kr_gpio_out, *gpioval); 128 + spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags); 131 129 132 130 return 0; 133 131 } ··· 143 145 enum i2c_type line, 144 146 enum i2c_state *curr_statep) 145 147 { 146 - u64 read_val, write_val, mask; 148 + u64 read_val, mask; 147 149 int ret; 150 + unsigned long flags = 0; 148 151 149 152 /* check args */ 150 153 if (curr_statep == NULL) { ··· 153 154 goto bail; 154 155 } 155 156 156 - read_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extctrl); 157 157 /* config line to be an input */ 158 158 if (line == i2c_line_scl) 159 159 mask = dd->ipath_gpio_scl; 160 160 else 161 161 mask = dd->ipath_gpio_sda; 162 - write_val = read_val & ~mask; 163 - ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, write_val); 162 + 163 + spin_lock_irqsave(&dd->ipath_gpio_lock, flags); 164 + dd->ipath_extctrl &= ~mask; 165 + ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, dd->ipath_extctrl); 166 + /* 167 + * Below is very unlikely to reflect true input state if Output 168 + * Enable actually changed. 169 + */ 164 170 read_val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus); 171 + spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags); 165 172 166 173 if (read_val & mask) 167 174 *curr_statep = i2c_line_high; ··· 197 192 198 193 static void scl_out(struct ipath_devdata *dd, u8 bit) 199 194 { 195 + udelay(1); 200 196 i2c_gpio_set(dd, i2c_line_scl, bit ? i2c_line_high : i2c_line_low); 201 197 202 198 i2c_wait_for_writes(dd); ··· 320 314 int clock_cycles_left = 9; 321 315 u64 *gpioval = &dd->ipath_gpio_out; 322 316 int ret; 317 + unsigned long flags; 323 318 324 - eeprom_init = 1; 319 + spin_lock_irqsave(&dd->ipath_gpio_lock, flags); 320 + /* Make sure shadows are consistent */ 321 + dd->ipath_extctrl = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extctrl); 325 322 *gpioval = ipath_read_kreg64(dd, dd->ipath_kregs->kr_gpio_out); 323 + spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags); 324 + 326 325 ipath_cdbg(VERBOSE, "Resetting i2c eeprom; initial gpioout reg " 327 326 "is %llx\n", (unsigned long long) *gpioval); 328 327 328 + eeprom_init = 1; 329 329 /* 330 330 * This is to get the i2c into a known state, by first going low, 331 331 * then tristate sda (and then tristate scl as first thing ··· 367 355 * @len: number of bytes to receive 368 356 */ 369 357 370 - int ipath_eeprom_read(struct ipath_devdata *dd, u8 eeprom_offset, 371 - void *buffer, int len) 358 + static int ipath_eeprom_internal_read(struct ipath_devdata *dd, 359 + u8 eeprom_offset, void *buffer, int len) 372 360 { 373 361 /* compiler complains unless initialized */ 374 362 u8 single_byte = 0; ··· 418 406 return ret; 419 407 } 420 408 409 + 421 410 /** 422 411 * ipath_eeprom_write - writes data to the eeprom via I2C 423 412 * @dd: the infinipath device ··· 426 413 * @buffer: data to write 427 414 * @len: number of bytes to write 428 415 */ 429 - int ipath_eeprom_write(struct ipath_devdata *dd, u8 eeprom_offset, 430 - const void *buffer, int len) 416 + int ipath_eeprom_internal_write(struct ipath_devdata *dd, u8 eeprom_offset, 417 + const void *buffer, int len) 431 418 { 432 419 u8 single_byte; 433 420 int sub_len; ··· 501 488 return ret; 502 489 } 503 490 491 + /* 492 + * The public entry-points ipath_eeprom_read() and ipath_eeprom_write() 493 + * are now just wrappers around the internal functions. 494 + */ 495 + int ipath_eeprom_read(struct ipath_devdata *dd, u8 eeprom_offset, 496 + void *buff, int len) 497 + { 498 + int ret; 499 + 500 + ret = down_interruptible(&dd->ipath_eep_sem); 501 + if (!ret) { 502 + ret = ipath_eeprom_internal_read(dd, eeprom_offset, buff, len); 503 + up(&dd->ipath_eep_sem); 504 + } 505 + 506 + return ret; 507 + } 508 + 509 + int ipath_eeprom_write(struct ipath_devdata *dd, u8 eeprom_offset, 510 + const void *buff, int len) 511 + { 512 + int ret; 513 + 514 + ret = down_interruptible(&dd->ipath_eep_sem); 515 + if (!ret) { 516 + ret = ipath_eeprom_internal_write(dd, eeprom_offset, buff, len); 517 + up(&dd->ipath_eep_sem); 518 + } 519 + 520 + return ret; 521 + } 522 + 504 523 static u8 flash_csum(struct ipath_flash *ifp, int adjust) 505 524 { 506 525 u8 *ip = (u8 *) ifp; ··· 560 515 void *buf; 561 516 struct ipath_flash *ifp; 562 517 __be64 guid; 563 - int len; 518 + int len, eep_stat; 564 519 u8 csum, *bguid; 565 520 int t = dd->ipath_unit; 566 521 struct ipath_devdata *dd0 = ipath_lookup(0); ··· 604 559 goto bail; 605 560 } 606 561 607 - if (ipath_eeprom_read(dd, 0, buf, len)) { 562 + down(&dd->ipath_eep_sem); 563 + eep_stat = ipath_eeprom_internal_read(dd, 0, buf, len); 564 + up(&dd->ipath_eep_sem); 565 + 566 + if (eep_stat) { 608 567 ipath_dev_err(dd, "Failed reading GUID from eeprom\n"); 609 568 goto done; 610 569 } ··· 683 634 ipath_cdbg(VERBOSE, "Initted GUID to %llx from eeprom\n", 684 635 (unsigned long long) be64_to_cpu(dd->ipath_guid)); 685 636 637 + memcpy(&dd->ipath_eep_st_errs, &ifp->if_errcntp, IPATH_EEP_LOG_CNT); 638 + /* 639 + * Power-on (actually "active") hours are kept as little-endian value 640 + * in EEPROM, but as seconds in a (possibly as small as 24-bit) 641 + * atomic_t while running. 642 + */ 643 + atomic_set(&dd->ipath_active_time, 0); 644 + dd->ipath_eep_hrs = ifp->if_powerhour[0] | (ifp->if_powerhour[1] << 8); 645 + 686 646 done: 687 647 vfree(buf); 688 648 689 649 bail:; 650 + } 651 + 652 + /** 653 + * ipath_update_eeprom_log - copy active-time and error counters to eeprom 654 + * @dd: the infinipath device 655 + * 656 + * Although the time is kept as seconds in the ipath_devdata struct, it is 657 + * rounded to hours for re-write, as we have only 16 bits in EEPROM. 658 + * First-cut code reads whole (expected) struct ipath_flash, modifies, 659 + * re-writes. Future direction: read/write only what we need, assuming 660 + * that the EEPROM had to have been "good enough" for driver init, and 661 + * if not, we aren't making it worse. 662 + * 663 + */ 664 + 665 + int ipath_update_eeprom_log(struct ipath_devdata *dd) 666 + { 667 + void *buf; 668 + struct ipath_flash *ifp; 669 + int len, hi_water; 670 + uint32_t new_time, new_hrs; 671 + u8 csum; 672 + int ret, idx; 673 + unsigned long flags; 674 + 675 + /* first, check if we actually need to do anything. */ 676 + ret = 0; 677 + for (idx = 0; idx < IPATH_EEP_LOG_CNT; ++idx) { 678 + if (dd->ipath_eep_st_new_errs[idx]) { 679 + ret = 1; 680 + break; 681 + } 682 + } 683 + new_time = atomic_read(&dd->ipath_active_time); 684 + 685 + if (ret == 0 && new_time < 3600) 686 + return 0; 687 + 688 + /* 689 + * The quick-check above determined that there is something worthy 690 + * of logging, so get current contents and do a more detailed idea. 691 + */ 692 + len = offsetof(struct ipath_flash, if_future); 693 + buf = vmalloc(len); 694 + ret = 1; 695 + if (!buf) { 696 + ipath_dev_err(dd, "Couldn't allocate memory to read %u " 697 + "bytes from eeprom for logging\n", len); 698 + goto bail; 699 + } 700 + 701 + /* Grab semaphore and read current EEPROM. If we get an 702 + * error, let go, but if not, keep it until we finish write. 703 + */ 704 + ret = down_interruptible(&dd->ipath_eep_sem); 705 + if (ret) { 706 + ipath_dev_err(dd, "Unable to acquire EEPROM for logging\n"); 707 + goto free_bail; 708 + } 709 + ret = ipath_eeprom_internal_read(dd, 0, buf, len); 710 + if (ret) { 711 + up(&dd->ipath_eep_sem); 712 + ipath_dev_err(dd, "Unable read EEPROM for logging\n"); 713 + goto free_bail; 714 + } 715 + ifp = (struct ipath_flash *)buf; 716 + 717 + csum = flash_csum(ifp, 0); 718 + if (csum != ifp->if_csum) { 719 + up(&dd->ipath_eep_sem); 720 + ipath_dev_err(dd, "EEPROM cks err (0x%02X, S/B 0x%02X)\n", 721 + csum, ifp->if_csum); 722 + ret = 1; 723 + goto free_bail; 724 + } 725 + hi_water = 0; 726 + spin_lock_irqsave(&dd->ipath_eep_st_lock, flags); 727 + for (idx = 0; idx < IPATH_EEP_LOG_CNT; ++idx) { 728 + int new_val = dd->ipath_eep_st_new_errs[idx]; 729 + if (new_val) { 730 + /* 731 + * If we have seen any errors, add to EEPROM values 732 + * We need to saturate at 0xFF (255) and we also 733 + * would need to adjust the checksum if we were 734 + * trying to minimize EEPROM traffic 735 + * Note that we add to actual current count in EEPROM, 736 + * in case it was altered while we were running. 737 + */ 738 + new_val += ifp->if_errcntp[idx]; 739 + if (new_val > 0xFF) 740 + new_val = 0xFF; 741 + if (ifp->if_errcntp[idx] != new_val) { 742 + ifp->if_errcntp[idx] = new_val; 743 + hi_water = offsetof(struct ipath_flash, 744 + if_errcntp) + idx; 745 + } 746 + /* 747 + * update our shadow (used to minimize EEPROM 748 + * traffic), to match what we are about to write. 749 + */ 750 + dd->ipath_eep_st_errs[idx] = new_val; 751 + dd->ipath_eep_st_new_errs[idx] = 0; 752 + } 753 + } 754 + /* 755 + * now update active-time. We would like to round to the nearest hour 756 + * but unless atomic_t are sure to be proper signed ints we cannot, 757 + * because we need to account for what we "transfer" to EEPROM and 758 + * if we log an hour at 31 minutes, then we would need to set 759 + * active_time to -29 to accurately count the _next_ hour. 760 + */ 761 + if (new_time > 3600) { 762 + new_hrs = new_time / 3600; 763 + atomic_sub((new_hrs * 3600), &dd->ipath_active_time); 764 + new_hrs += dd->ipath_eep_hrs; 765 + if (new_hrs > 0xFFFF) 766 + new_hrs = 0xFFFF; 767 + dd->ipath_eep_hrs = new_hrs; 768 + if ((new_hrs & 0xFF) != ifp->if_powerhour[0]) { 769 + ifp->if_powerhour[0] = new_hrs & 0xFF; 770 + hi_water = offsetof(struct ipath_flash, if_powerhour); 771 + } 772 + if ((new_hrs >> 8) != ifp->if_powerhour[1]) { 773 + ifp->if_powerhour[1] = new_hrs >> 8; 774 + hi_water = offsetof(struct ipath_flash, if_powerhour) 775 + + 1; 776 + } 777 + } 778 + /* 779 + * There is a tiny possibility that we could somehow fail to write 780 + * the EEPROM after updating our shadows, but problems from holding 781 + * the spinlock too long are a much bigger issue. 782 + */ 783 + spin_unlock_irqrestore(&dd->ipath_eep_st_lock, flags); 784 + if (hi_water) { 785 + /* we made some change to the data, uopdate cksum and write */ 786 + csum = flash_csum(ifp, 1); 787 + ret = ipath_eeprom_internal_write(dd, 0, buf, hi_water + 1); 788 + } 789 + up(&dd->ipath_eep_sem); 790 + if (ret) 791 + ipath_dev_err(dd, "Failed updating EEPROM\n"); 792 + 793 + free_bail: 794 + vfree(buf); 795 + bail: 796 + return ret; 797 + 798 + } 799 + 800 + /** 801 + * ipath_inc_eeprom_err - increment one of the four error counters 802 + * that are logged to EEPROM. 803 + * @dd: the infinipath device 804 + * @eidx: 0..3, the counter to increment 805 + * @incr: how much to add 806 + * 807 + * Each counter is 8-bits, and saturates at 255 (0xFF). They 808 + * are copied to the EEPROM (aka flash) whenever ipath_update_eeprom_log() 809 + * is called, but it can only be called in a context that allows sleep. 810 + * This function can be called even at interrupt level. 811 + */ 812 + 813 + void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr) 814 + { 815 + uint new_val; 816 + unsigned long flags; 817 + 818 + spin_lock_irqsave(&dd->ipath_eep_st_lock, flags); 819 + new_val = dd->ipath_eep_st_new_errs[eidx] + incr; 820 + if (new_val > 255) 821 + new_val = 255; 822 + dd->ipath_eep_st_new_errs[eidx] = new_val; 823 + spin_unlock_irqrestore(&dd->ipath_eep_st_lock, flags); 824 + return; 690 825 }
+157 -66
drivers/infiniband/hw/ipath/ipath_file_ops.c
··· 396 396 "TID %u, vaddr %lx, physaddr %llx pgp %p\n", 397 397 tid, vaddr, (unsigned long long) physaddr, 398 398 pagep[i]); 399 - dd->ipath_f_put_tid(dd, &tidbase[tid], 1, physaddr); 399 + dd->ipath_f_put_tid(dd, &tidbase[tid], RCVHQ_RCV_TYPE_EXPECTED, 400 + physaddr); 400 401 /* 401 402 * don't check this tid in ipath_portshadow, since we 402 403 * just filled it in; start with the next one. ··· 423 422 if (dd->ipath_pageshadow[porttid + tid]) { 424 423 ipath_cdbg(VERBOSE, "Freeing TID %u\n", 425 424 tid); 426 - dd->ipath_f_put_tid(dd, &tidbase[tid], 1, 425 + dd->ipath_f_put_tid(dd, &tidbase[tid], 426 + RCVHQ_RCV_TYPE_EXPECTED, 427 427 dd->ipath_tidinvalid); 428 428 pci_unmap_page(dd->pcidev, 429 429 dd->ipath_physshadow[porttid + tid], ··· 540 538 if (dd->ipath_pageshadow[porttid + tid]) { 541 539 ipath_cdbg(VERBOSE, "PID %u freeing TID %u\n", 542 540 pd->port_pid, tid); 543 - dd->ipath_f_put_tid(dd, &tidbase[tid], 1, 541 + dd->ipath_f_put_tid(dd, &tidbase[tid], 542 + RCVHQ_RCV_TYPE_EXPECTED, 544 543 dd->ipath_tidinvalid); 545 544 pci_unmap_page(dd->pcidev, 546 545 dd->ipath_physshadow[porttid + tid], ··· 924 921 (u64 __iomem *) 925 922 ((char __iomem *) 926 923 dd->ipath_kregbase + 927 - dd->ipath_rcvegrbase), 0, pa); 924 + dd->ipath_rcvegrbase), 925 + RCVHQ_RCV_TYPE_EAGER, pa); 928 926 pa += egrsize; 929 927 } 930 928 cond_resched(); /* don't hog the cpu */ ··· 1341 1337 return ret; 1342 1338 } 1343 1339 1340 + static unsigned int ipath_poll_urgent(struct ipath_portdata *pd, 1341 + struct file *fp, 1342 + struct poll_table_struct *pt) 1343 + { 1344 + unsigned pollflag = 0; 1345 + struct ipath_devdata *dd; 1346 + 1347 + dd = pd->port_dd; 1348 + 1349 + if (test_bit(IPATH_PORT_WAITING_OVERFLOW, &pd->int_flag)) { 1350 + pollflag |= POLLERR; 1351 + clear_bit(IPATH_PORT_WAITING_OVERFLOW, &pd->int_flag); 1352 + } 1353 + 1354 + if (test_bit(IPATH_PORT_WAITING_URG, &pd->int_flag)) { 1355 + pollflag |= POLLIN | POLLRDNORM; 1356 + clear_bit(IPATH_PORT_WAITING_URG, &pd->int_flag); 1357 + } 1358 + 1359 + if (!pollflag) { 1360 + set_bit(IPATH_PORT_WAITING_URG, &pd->port_flag); 1361 + if (pd->poll_type & IPATH_POLL_TYPE_OVERFLOW) 1362 + set_bit(IPATH_PORT_WAITING_OVERFLOW, 1363 + &pd->port_flag); 1364 + 1365 + poll_wait(fp, &pd->port_wait, pt); 1366 + } 1367 + 1368 + return pollflag; 1369 + } 1370 + 1371 + static unsigned int ipath_poll_next(struct ipath_portdata *pd, 1372 + struct file *fp, 1373 + struct poll_table_struct *pt) 1374 + { 1375 + u32 head, tail; 1376 + unsigned pollflag = 0; 1377 + struct ipath_devdata *dd; 1378 + 1379 + dd = pd->port_dd; 1380 + 1381 + head = ipath_read_ureg32(dd, ur_rcvhdrhead, pd->port_port); 1382 + tail = *(volatile u64 *)pd->port_rcvhdrtail_kvaddr; 1383 + 1384 + if (test_bit(IPATH_PORT_WAITING_OVERFLOW, &pd->int_flag)) { 1385 + pollflag |= POLLERR; 1386 + clear_bit(IPATH_PORT_WAITING_OVERFLOW, &pd->int_flag); 1387 + } 1388 + 1389 + if (tail != head || 1390 + test_bit(IPATH_PORT_WAITING_RCV, &pd->int_flag)) { 1391 + pollflag |= POLLIN | POLLRDNORM; 1392 + clear_bit(IPATH_PORT_WAITING_RCV, &pd->int_flag); 1393 + } 1394 + 1395 + if (!pollflag) { 1396 + set_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag); 1397 + if (pd->poll_type & IPATH_POLL_TYPE_OVERFLOW) 1398 + set_bit(IPATH_PORT_WAITING_OVERFLOW, 1399 + &pd->port_flag); 1400 + 1401 + set_bit(pd->port_port + INFINIPATH_R_INTRAVAIL_SHIFT, 1402 + &dd->ipath_rcvctrl); 1403 + 1404 + ipath_write_kreg(dd, dd->ipath_kregs->kr_rcvctrl, 1405 + dd->ipath_rcvctrl); 1406 + 1407 + if (dd->ipath_rhdrhead_intr_off) /* arm rcv interrupt */ 1408 + ipath_write_ureg(dd, ur_rcvhdrhead, 1409 + dd->ipath_rhdrhead_intr_off | head, 1410 + pd->port_port); 1411 + 1412 + poll_wait(fp, &pd->port_wait, pt); 1413 + } 1414 + 1415 + return pollflag; 1416 + } 1417 + 1344 1418 static unsigned int ipath_poll(struct file *fp, 1345 1419 struct poll_table_struct *pt) 1346 1420 { 1347 1421 struct ipath_portdata *pd; 1348 - u32 head, tail; 1349 - int bit; 1350 - unsigned pollflag = 0; 1351 - struct ipath_devdata *dd; 1422 + unsigned pollflag; 1352 1423 1353 1424 pd = port_fp(fp); 1354 1425 if (!pd) 1355 - goto bail; 1356 - dd = pd->port_dd; 1426 + pollflag = 0; 1427 + else if (pd->poll_type & IPATH_POLL_TYPE_URGENT) 1428 + pollflag = ipath_poll_urgent(pd, fp, pt); 1429 + else 1430 + pollflag = ipath_poll_next(pd, fp, pt); 1357 1431 1358 - bit = pd->port_port + INFINIPATH_R_INTRAVAIL_SHIFT; 1359 - set_bit(bit, &dd->ipath_rcvctrl); 1360 - 1361 - /* 1362 - * Before blocking, make sure that head is still == tail, 1363 - * reading from the chip, so we can be sure the interrupt 1364 - * enable has made it to the chip. If not equal, disable 1365 - * interrupt again and return immediately. This avoids races, 1366 - * and the overhead of the chip read doesn't matter much at 1367 - * this point, since we are waiting for something anyway. 1368 - */ 1369 - 1370 - ipath_write_kreg(dd, dd->ipath_kregs->kr_rcvctrl, 1371 - dd->ipath_rcvctrl); 1372 - 1373 - head = ipath_read_ureg32(dd, ur_rcvhdrhead, pd->port_port); 1374 - tail = ipath_read_ureg32(dd, ur_rcvhdrtail, pd->port_port); 1375 - 1376 - if (tail == head) { 1377 - set_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag); 1378 - if (dd->ipath_rhdrhead_intr_off) /* arm rcv interrupt */ 1379 - (void)ipath_write_ureg(dd, ur_rcvhdrhead, 1380 - dd->ipath_rhdrhead_intr_off 1381 - | head, pd->port_port); 1382 - poll_wait(fp, &pd->port_wait, pt); 1383 - 1384 - if (test_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag)) { 1385 - /* timed out, no packets received */ 1386 - clear_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag); 1387 - pd->port_rcvwait_to++; 1388 - } 1389 - else 1390 - pollflag = POLLIN | POLLRDNORM; 1391 - } 1392 - else { 1393 - /* it's already happened; don't do wait_event overhead */ 1394 - pollflag = POLLIN | POLLRDNORM; 1395 - pd->port_rcvnowait++; 1396 - } 1397 - 1398 - clear_bit(bit, &dd->ipath_rcvctrl); 1399 - ipath_write_kreg(dd, dd->ipath_kregs->kr_rcvctrl, 1400 - dd->ipath_rcvctrl); 1401 - 1402 - bail: 1403 1432 return pollflag; 1433 + } 1434 + 1435 + static int ipath_supports_subports(int user_swmajor, int user_swminor) 1436 + { 1437 + /* no subport implementation prior to software version 1.3 */ 1438 + return (user_swmajor > 1) || (user_swminor >= 3); 1439 + } 1440 + 1441 + static int ipath_compatible_subports(int user_swmajor, int user_swminor) 1442 + { 1443 + /* this code is written long-hand for clarity */ 1444 + if (IPATH_USER_SWMAJOR != user_swmajor) { 1445 + /* no promise of compatibility if major mismatch */ 1446 + return 0; 1447 + } 1448 + if (IPATH_USER_SWMAJOR == 1) { 1449 + switch (IPATH_USER_SWMINOR) { 1450 + case 0: 1451 + case 1: 1452 + case 2: 1453 + /* no subport implementation so cannot be compatible */ 1454 + return 0; 1455 + case 3: 1456 + /* 3 is only compatible with itself */ 1457 + return user_swminor == 3; 1458 + default: 1459 + /* >= 4 are compatible (or are expected to be) */ 1460 + return user_swminor >= 4; 1461 + } 1462 + } 1463 + /* make no promises yet for future major versions */ 1464 + return 0; 1404 1465 } 1405 1466 1406 1467 static int init_subports(struct ipath_devdata *dd, ··· 1477 1408 size_t size; 1478 1409 1479 1410 /* 1480 - * If the user is requesting zero or one port, 1411 + * If the user is requesting zero subports, 1481 1412 * skip the subport allocation. 1482 1413 */ 1483 - if (uinfo->spu_subport_cnt <= 1) 1414 + if (uinfo->spu_subport_cnt <= 0) 1484 1415 goto bail; 1485 1416 1486 - /* Old user binaries don't know about new subport implementation */ 1487 - if ((uinfo->spu_userversion & 0xffff) != IPATH_USER_SWMINOR) { 1417 + /* Self-consistency check for ipath_compatible_subports() */ 1418 + if (ipath_supports_subports(IPATH_USER_SWMAJOR, IPATH_USER_SWMINOR) && 1419 + !ipath_compatible_subports(IPATH_USER_SWMAJOR, 1420 + IPATH_USER_SWMINOR)) { 1488 1421 dev_info(&dd->pcidev->dev, 1489 - "Mismatched user minor version (%d) and driver " 1490 - "minor version (%d) while port sharing. Ensure " 1422 + "Inconsistent ipath_compatible_subports()\n"); 1423 + goto bail; 1424 + } 1425 + 1426 + /* Check for subport compatibility */ 1427 + if (!ipath_compatible_subports(uinfo->spu_userversion >> 16, 1428 + uinfo->spu_userversion & 0xffff)) { 1429 + dev_info(&dd->pcidev->dev, 1430 + "Mismatched user version (%d.%d) and driver " 1431 + "version (%d.%d) while port sharing. Ensure " 1491 1432 "that driver and library are from the same " 1492 1433 "release.\n", 1434 + (int) (uinfo->spu_userversion >> 16), 1493 1435 (int) (uinfo->spu_userversion & 0xffff), 1436 + IPATH_USER_SWMAJOR, 1494 1437 IPATH_USER_SWMINOR); 1495 1438 goto bail; 1496 1439 } ··· 1806 1725 return fp->private_data ? 0 : -ENOMEM; 1807 1726 } 1808 1727 1809 - 1810 1728 /* Get port early, so can set affinity prior to memory allocation */ 1811 1729 static int ipath_assign_port(struct file *fp, 1812 1730 const struct ipath_user_info *uinfo) 1813 1731 { 1814 1732 int ret; 1815 1733 int i_minor; 1816 - unsigned swminor; 1734 + unsigned swmajor, swminor; 1817 1735 1818 1736 /* Check to be sure we haven't already initialized this file */ 1819 1737 if (port_fp(fp)) { ··· 1821 1741 } 1822 1742 1823 1743 /* for now, if major version is different, bail */ 1824 - if ((uinfo->spu_userversion >> 16) != IPATH_USER_SWMAJOR) { 1744 + swmajor = uinfo->spu_userversion >> 16; 1745 + if (swmajor != IPATH_USER_SWMAJOR) { 1825 1746 ipath_dbg("User major version %d not same as driver " 1826 1747 "major %d\n", uinfo->spu_userversion >> 16, 1827 1748 IPATH_USER_SWMAJOR); ··· 1837 1756 1838 1757 mutex_lock(&ipath_mutex); 1839 1758 1840 - if (swminor == IPATH_USER_SWMINOR && uinfo->spu_subport_cnt && 1759 + if (ipath_compatible_subports(swmajor, swminor) && 1760 + uinfo->spu_subport_cnt && 1841 1761 (ret = find_shared_port(fp, uinfo))) { 1842 1762 mutex_unlock(&ipath_mutex); 1843 1763 if (ret > 0) ··· 2102 2020 info.port = pd->port_port; 2103 2021 info.subport = subport; 2104 2022 /* Don't return new fields if old library opened the port. */ 2105 - if ((pd->userversion & 0xffff) == IPATH_USER_SWMINOR) { 2023 + if (ipath_supports_subports(pd->userversion >> 16, 2024 + pd->userversion & 0xffff)) { 2106 2025 /* Number of user ports available for this device. */ 2107 2026 info.num_ports = pd->port_dd->ipath_cfgports - 1; 2108 2027 info.num_subports = pd->port_subport_cnt; ··· 2206 2123 src = NULL; 2207 2124 dest = NULL; 2208 2125 break; 2126 + case IPATH_CMD_POLL_TYPE: 2127 + copy = sizeof(cmd.cmd.poll_type); 2128 + dest = &cmd.cmd.poll_type; 2129 + src = &ucmd->cmd.poll_type; 2130 + break; 2209 2131 default: 2210 2132 ret = -EINVAL; 2211 2133 goto bail; ··· 2282 2194 break; 2283 2195 case IPATH_CMD_PIOAVAILUPD: 2284 2196 ret = ipath_force_pio_avail_update(pd->port_dd); 2197 + break; 2198 + case IPATH_CMD_POLL_TYPE: 2199 + pd->poll_type = cmd.cmd.poll_type; 2285 2200 break; 2286 2201 } 2287 2202
+7 -2
drivers/infiniband/hw/ipath/ipath_fs.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 257 257 /* Notimpl InitType (actually, an SMA decision) */ 258 258 /* VLHighLimit is 0 (only one VL) */ 259 259 ; /* VLArbitrationHighCap is 0 (only one VL) */ 260 + /* 261 + * Note: the chips support a maximum MTU of 4096, but the driver 262 + * hasn't implemented this feature yet, so set the maximum 263 + * to 2048. 264 + */ 260 265 portinfo[10] = /* VLArbitrationLowCap is 0 (only one VL) */ 261 266 /* InitTypeReply is SMA decision */ 262 - (5 << 16) /* MTUCap 4096 */ 267 + (4 << 16) /* MTUCap 2048 */ 263 268 | (7 << 13) /* VLStallCount */ 264 269 | (0x1f << 8) /* HOQLife */ 265 270 | (1 << 4)
+57 -44
drivers/infiniband/hw/ipath/ipath_iba6110.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 36 36 * HT chip. 37 37 */ 38 38 39 + #include <linux/vmalloc.h> 39 40 #include <linux/pci.h> 40 41 #include <linux/delay.h> 41 42 #include <linux/htirq.h> ··· 440 439 u32 bits, ctrl; 441 440 int isfatal = 0; 442 441 char bitsmsg[64]; 442 + int log_idx; 443 443 444 444 hwerrs = ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus); 445 445 ··· 468 466 hwerrs&~INFINIPATH_HWE_MEMBISTFAILED); 469 467 470 468 hwerrs &= dd->ipath_hwerrmask; 469 + 470 + /* We log some errors to EEPROM, check if we have any of those. */ 471 + for (log_idx = 0; log_idx < IPATH_EEP_LOG_CNT; ++log_idx) 472 + if (hwerrs & dd->ipath_eep_st_masks[log_idx].hwerrs_to_log) 473 + ipath_inc_eeprom_err(dd, log_idx, 1); 471 474 472 475 /* 473 476 * make sure we get this much out, unless told to be quiet, ··· 509 502 if (!hwerrs) { 510 503 ipath_dbg("Clearing freezemode on ignored or " 511 504 "recovered hardware error\n"); 512 - ctrl &= ~INFINIPATH_C_FREEZEMODE; 513 - ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 514 - ctrl); 505 + ipath_clear_freeze(dd); 515 506 } 516 507 } 517 508 ··· 677 672 if (n) 678 673 snprintf(name, namelen, "%s", n); 679 674 675 + if (dd->ipath_boardrev != 6 && dd->ipath_boardrev != 7 && 676 + dd->ipath_boardrev != 11) { 677 + ipath_dev_err(dd, "Unsupported InfiniPath board %s!\n", name); 678 + ret = 1; 679 + goto bail; 680 + } 680 681 if (dd->ipath_majrev != 3 || (dd->ipath_minrev < 2 || 681 - dd->ipath_minrev > 3)) { 682 + dd->ipath_minrev > 4)) { 682 683 /* 683 - * This version of the driver only supports Rev 3.2 and 3.3 684 + * This version of the driver only supports Rev 3.2 - 3.4 684 685 */ 685 686 ipath_dev_err(dd, 686 687 "Unsupported InfiniPath hardware revision %u.%u!\n", ··· 700 689 * copies 701 690 */ 702 691 dd->ipath_flags |= IPATH_32BITCOUNTERS; 692 + dd->ipath_flags |= IPATH_GPIO_INTR; 703 693 if (dd->ipath_htspeed != 800) 704 694 ipath_dev_err(dd, 705 695 "Incorrectly configured for HT @ %uMHz\n", 706 696 dd->ipath_htspeed); 707 - if (dd->ipath_boardrev == 7 || dd->ipath_boardrev == 11 || 708 - dd->ipath_boardrev == 6) 709 - dd->ipath_flags |= IPATH_GPIO_INTR; 710 - else 711 - dd->ipath_flags |= IPATH_POLL_RX_INTR; 712 - if (dd->ipath_boardrev == 8) { /* LS/X-1 */ 713 - u64 val; 714 - val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_extstatus); 715 - if (val & INFINIPATH_EXTS_SERDESSEL) { 716 - /* 717 - * hardware disabled 718 - * 719 - * This means that the chip is hardware disabled, 720 - * and will not be able to bring up the link, 721 - * in any case. We special case this and abort 722 - * early, to avoid later messages. We also set 723 - * the DISABLED status bit 724 - */ 725 - ipath_dbg("Unit %u is hardware-disabled\n", 726 - dd->ipath_unit); 727 - *dd->ipath_statusp |= IPATH_STATUS_DISABLED; 728 - /* this value is handled differently */ 729 - ret = 2; 730 - goto bail; 731 - } 732 - } 733 697 ret = 0; 734 698 735 699 bail: ··· 1044 1058 u64 lst, u64 ltst) 1045 1059 { 1046 1060 u64 extctl; 1061 + unsigned long flags = 0; 1047 1062 1048 1063 /* the diags use the LED to indicate diag info, so we leave 1049 1064 * the external LED alone when the diags are running */ 1050 1065 if (ipath_diag_inuse) 1051 1066 return; 1052 1067 1068 + /* Allow override of LED display for, e.g. Locating system in rack */ 1069 + if (dd->ipath_led_override) { 1070 + ltst = (dd->ipath_led_override & IPATH_LED_PHYS) 1071 + ? INFINIPATH_IBCS_LT_STATE_LINKUP 1072 + : INFINIPATH_IBCS_LT_STATE_DISABLED; 1073 + lst = (dd->ipath_led_override & IPATH_LED_LOG) 1074 + ? INFINIPATH_IBCS_L_STATE_ACTIVE 1075 + : INFINIPATH_IBCS_L_STATE_DOWN; 1076 + } 1077 + 1078 + spin_lock_irqsave(&dd->ipath_gpio_lock, flags); 1053 1079 /* 1054 1080 * start by setting both LED control bits to off, then turn 1055 1081 * on the appropriate bit(s). ··· 1090 1092 } 1091 1093 dd->ipath_extctrl = extctl; 1092 1094 ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, extctl); 1095 + spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags); 1093 1096 } 1094 1097 1095 1098 static void ipath_init_ht_variables(struct ipath_devdata *dd) ··· 1156 1157 1157 1158 dd->ipath_i_rcvavail_mask = INFINIPATH_I_RCVAVAIL_MASK; 1158 1159 dd->ipath_i_rcvurg_mask = INFINIPATH_I_RCVURG_MASK; 1160 + 1161 + /* 1162 + * EEPROM error log 0 is TXE Parity errors. 1 is RXE Parity. 1163 + * 2 is Some Misc, 3 is reserved for future. 1164 + */ 1165 + dd->ipath_eep_st_masks[0].hwerrs_to_log = 1166 + INFINIPATH_HWE_TXEMEMPARITYERR_MASK << 1167 + INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT; 1168 + 1169 + dd->ipath_eep_st_masks[1].hwerrs_to_log = 1170 + INFINIPATH_HWE_RXEMEMPARITYERR_MASK << 1171 + INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT; 1172 + 1173 + dd->ipath_eep_st_masks[2].errs_to_log = 1174 + INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET; 1175 + 1159 1176 } 1160 1177 1161 1178 /** ··· 1387 1372 * ipath_pe_put_tid - write a TID in chip 1388 1373 * @dd: the infinipath device 1389 1374 * @tidptr: pointer to the expected TID (in chip) to udpate 1390 - * @tidtype: 0 for eager, 1 for expected 1375 + * @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected 1391 1376 * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing 1392 1377 * 1393 1378 * This exists as a separate routine to allow for special locking etc. ··· 1408 1393 "40 bits, using only 40!!!\n", pa); 1409 1394 pa &= INFINIPATH_RT_ADDR_MASK; 1410 1395 } 1411 - if (type == 0) 1396 + if (type == RCVHQ_RCV_TYPE_EAGER) 1412 1397 pa |= dd->ipath_tidtemplate; 1413 1398 else { 1414 1399 /* in words (fixed, full page). */ ··· 1448 1433 port * dd->ipath_rcvtidcnt * 1449 1434 sizeof(*tidbase)); 1450 1435 for (i = 0; i < dd->ipath_rcvtidcnt; i++) 1451 - ipath_ht_put_tid(dd, &tidbase[i], 1, dd->ipath_tidinvalid); 1436 + ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED, 1437 + dd->ipath_tidinvalid); 1452 1438 1453 1439 tidbase = (u64 __iomem *) ((char __iomem *)(dd->ipath_kregbase) + 1454 1440 dd->ipath_rcvegrbase + ··· 1457 1441 sizeof(*tidbase)); 1458 1442 1459 1443 for (i = 0; i < dd->ipath_rcvegrcnt; i++) 1460 - ipath_ht_put_tid(dd, &tidbase[i], 0, dd->ipath_tidinvalid); 1444 + ipath_ht_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER, 1445 + dd->ipath_tidinvalid); 1461 1446 } 1462 1447 1463 1448 /** ··· 1545 1528 writel(16, piobuf); 1546 1529 piobuf += pioincr; 1547 1530 } 1548 - /* 1549 - * self-clearing 1550 - */ 1551 - ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 1552 - INFINIPATH_S_ABORT); 1553 1531 1554 1532 ipath_get_eeprom_info(dd); 1555 1533 if (dd->ipath_boardrev == 5 && dd->ipath_serial[0] == '1' && ··· 1555 1543 * with 128, rather than 112. 1556 1544 */ 1557 1545 dd->ipath_flags |= IPATH_GPIO_INTR; 1558 - dd->ipath_flags &= ~IPATH_POLL_RX_INTR; 1559 - } 1546 + } else 1547 + ipath_dev_err(dd, "Unsupported InfiniPath serial " 1548 + "number %.16s!\n", dd->ipath_serial); 1549 + 1560 1550 return 0; 1561 1551 } 1562 1552 ··· 1575 1561 } 1576 1562 dev_info(&dd->pcidev->dev, 1577 1563 "Recovering from TXE PIO parity error\n"); 1578 - ipath_disarm_senderrbufs(dd, 1); 1579 1564 return 1; 1580 1565 } 1581 1566
+55 -37
drivers/infiniband/hw/ipath/ipath_iba6120.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 296 296 #define IPATH_GPIO_SCL (1ULL << \ 297 297 (_IPATH_GPIO_SCL_NUM+INFINIPATH_EXTC_GPIOOE_SHIFT)) 298 298 299 - /* 300 - * Rev2 silicon allows suppressing check for ArmLaunch errors. 301 - * this can speed up short packet sends on systems that do 302 - * not guaranteee write-order. 303 - */ 304 - #define INFINIPATH_XGXS_SUPPRESS_ARMLAUNCH_ERR (1ULL<<63) 305 - 306 299 /* 6120 specific hardware errors... */ 307 300 static const struct ipath_hwerror_msgs ipath_6120_hwerror_msgs[] = { 308 301 INFINIPATH_HWE_MSG(PCIEPOISONEDTLP, "PCIe Poisoned TLP"), ··· 340 347 u32 bits, ctrl; 341 348 int isfatal = 0; 342 349 char bitsmsg[64]; 350 + int log_idx; 343 351 344 352 hwerrs = ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus); 345 353 if (!hwerrs) { ··· 367 373 hwerrs&~INFINIPATH_HWE_MEMBISTFAILED); 368 374 369 375 hwerrs &= dd->ipath_hwerrmask; 376 + 377 + /* We log some errors to EEPROM, check if we have any of those. */ 378 + for (log_idx = 0; log_idx < IPATH_EEP_LOG_CNT; ++log_idx) 379 + if (hwerrs & dd->ipath_eep_st_masks[log_idx].hwerrs_to_log) 380 + ipath_inc_eeprom_err(dd, log_idx, 1); 370 381 371 382 /* 372 383 * make sure we get this much out, unless told to be quiet, ··· 430 431 *dd->ipath_statusp |= IPATH_STATUS_HWERROR; 431 432 dd->ipath_flags &= ~IPATH_INITTED; 432 433 } else { 433 - ipath_dbg("Clearing freezemode on ignored hardware " 434 - "error\n"); 435 - ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 436 - dd->ipath_control); 434 + static u32 freeze_cnt; 435 + 436 + freeze_cnt++; 437 + ipath_dbg("Clearing freezemode on ignored or recovered " 438 + "hardware error (%u)\n", freeze_cnt); 439 + ipath_clear_freeze(dd); 437 440 } 438 441 } 439 442 ··· 681 680 val |= dd->ipath_rx_pol_inv << 682 681 INFINIPATH_XGXS_RX_POL_SHIFT; 683 682 } 684 - if (dd->ipath_minrev >= 2) { 685 - /* Rev 2. can tolerate multiple writes to PBC, and 686 - * allowing them can provide lower latency on some 687 - * CPUs, but this feature is off by default, only 688 - * turned on by setting D63 of XGXSconfig reg. 689 - * May want to make this conditional more 690 - * fine-grained in future. This is not exactly 691 - * related to XGXS, but where the bit ended up. 692 - */ 693 - val |= INFINIPATH_XGXS_SUPPRESS_ARMLAUNCH_ERR; 694 - } 695 683 if (val != prev_val) 696 684 ipath_write_kreg(dd, dd->ipath_kregs->kr_xgxsconfig, val); 697 685 ··· 781 791 u64 ltst) 782 792 { 783 793 u64 extctl; 794 + unsigned long flags = 0; 784 795 785 796 /* the diags use the LED to indicate diag info, so we leave 786 797 * the external LED alone when the diags are running */ 787 798 if (ipath_diag_inuse) 788 799 return; 789 800 801 + /* Allow override of LED display for, e.g. Locating system in rack */ 802 + if (dd->ipath_led_override) { 803 + ltst = (dd->ipath_led_override & IPATH_LED_PHYS) 804 + ? INFINIPATH_IBCS_LT_STATE_LINKUP 805 + : INFINIPATH_IBCS_LT_STATE_DISABLED; 806 + lst = (dd->ipath_led_override & IPATH_LED_LOG) 807 + ? INFINIPATH_IBCS_L_STATE_ACTIVE 808 + : INFINIPATH_IBCS_L_STATE_DOWN; 809 + } 810 + 811 + spin_lock_irqsave(&dd->ipath_gpio_lock, flags); 790 812 extctl = dd->ipath_extctrl & ~(INFINIPATH_EXTC_LED1PRIPORT_ON | 791 813 INFINIPATH_EXTC_LED2PRIPORT_ON); 792 814 ··· 808 806 extctl |= INFINIPATH_EXTC_LED1PRIPORT_ON; 809 807 dd->ipath_extctrl = extctl; 810 808 ipath_write_kreg(dd, dd->ipath_kregs->kr_extctrl, extctl); 809 + spin_unlock_irqrestore(&dd->ipath_gpio_lock, flags); 811 810 } 812 811 813 812 /** ··· 958 955 959 956 dd->ipath_i_rcvavail_mask = INFINIPATH_I_RCVAVAIL_MASK; 960 957 dd->ipath_i_rcvurg_mask = INFINIPATH_I_RCVURG_MASK; 958 + 959 + /* 960 + * EEPROM error log 0 is TXE Parity errors. 1 is RXE Parity. 961 + * 2 is Some Misc, 3 is reserved for future. 962 + */ 963 + dd->ipath_eep_st_masks[0].hwerrs_to_log = 964 + INFINIPATH_HWE_TXEMEMPARITYERR_MASK << 965 + INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT; 966 + 967 + /* Ignore errors in PIO/PBC on systems with unordered write-combining */ 968 + if (ipath_unordered_wc()) 969 + dd->ipath_eep_st_masks[0].hwerrs_to_log &= ~TXE_PIO_PARITY; 970 + 971 + dd->ipath_eep_st_masks[1].hwerrs_to_log = 972 + INFINIPATH_HWE_RXEMEMPARITYERR_MASK << 973 + INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT; 974 + 975 + dd->ipath_eep_st_masks[2].errs_to_log = 976 + INFINIPATH_E_INVALIDADDR | INFINIPATH_E_RESET; 977 + 978 + 961 979 } 962 980 963 981 /* setup the MSI stuff again after a reset. I'd like to just call ··· 1106 1082 * ipath_pe_put_tid - write a TID in chip 1107 1083 * @dd: the infinipath device 1108 1084 * @tidptr: pointer to the expected TID (in chip) to udpate 1109 - * @tidtype: 0 for eager, 1 for expected 1085 + * @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected 1110 1086 * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing 1111 1087 * 1112 1088 * This exists as a separate routine to allow for special locking etc. ··· 1132 1108 "BUG: Physical page address 0x%lx " 1133 1109 "has bits set in 31-29\n", pa); 1134 1110 1135 - if (type == 0) 1111 + if (type == RCVHQ_RCV_TYPE_EAGER) 1136 1112 pa |= dd->ipath_tidtemplate; 1137 1113 else /* for now, always full 4KB page */ 1138 1114 pa |= 2 << 29; ··· 1156 1132 * ipath_pe_put_tid_2 - write a TID in chip, Revision 2 or higher 1157 1133 * @dd: the infinipath device 1158 1134 * @tidptr: pointer to the expected TID (in chip) to udpate 1159 - * @tidtype: 0 for eager, 1 for expected 1135 + * @tidtype: RCVHQ_RCV_TYPE_EAGER (1) for eager, RCVHQ_RCV_TYPE_EXPECTED (0) for expected 1160 1136 * @pa: physical address of in memory buffer; ipath_tidinvalid if freeing 1161 1137 * 1162 1138 * This exists as a separate routine to allow for selection of the ··· 1181 1157 "BUG: Physical page address 0x%lx " 1182 1158 "has bits set in 31-29\n", pa); 1183 1159 1184 - if (type == 0) 1160 + if (type == RCVHQ_RCV_TYPE_EAGER) 1185 1161 pa |= dd->ipath_tidtemplate; 1186 1162 else /* for now, always full 4KB page */ 1187 1163 pa |= 2 << 29; ··· 1220 1196 port * dd->ipath_rcvtidcnt * sizeof(*tidbase)); 1221 1197 1222 1198 for (i = 0; i < dd->ipath_rcvtidcnt; i++) 1223 - ipath_pe_put_tid(dd, &tidbase[i], 0, tidinv); 1199 + ipath_pe_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED, 1200 + tidinv); 1224 1201 1225 1202 tidbase = (u64 __iomem *) 1226 1203 ((char __iomem *)(dd->ipath_kregbase) + ··· 1229 1204 port * dd->ipath_rcvegrcnt * sizeof(*tidbase)); 1230 1205 1231 1206 for (i = 0; i < dd->ipath_rcvegrcnt; i++) 1232 - ipath_pe_put_tid(dd, &tidbase[i], 1, tidinv); 1207 + ipath_pe_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER, 1208 + tidinv); 1233 1209 } 1234 1210 1235 1211 /** ··· 1337 1311 1338 1312 dd = pd->port_dd; 1339 1313 1340 - if (dd != NULL && dd->ipath_minrev >= 2) { 1341 - ipath_cdbg(PROC, "IBA6120 Rev2, allow multiple PBC write\n"); 1342 - kinfo->spi_runtime_flags |= IPATH_RUNTIME_PBC_REWRITE; 1343 - ipath_cdbg(PROC, "IBA6120 Rev2, allow loose DMA alignment\n"); 1344 - kinfo->spi_runtime_flags |= IPATH_RUNTIME_LOOSE_DMA_ALIGN; 1345 - } 1346 - 1347 1314 done: 1348 1315 kinfo->spi_runtime_flags |= IPATH_RUNTIME_PCIE; 1349 1316 return 0; ··· 1373 1354 dev_info(&dd->pcidev->dev, 1374 1355 "Recovering from TXE PIO parity error\n"); 1375 1356 } 1376 - ipath_disarm_senderrbufs(dd, 1); 1377 1357 return 1; 1378 1358 } 1379 1359
+21 -5
drivers/infiniband/hw/ipath/ipath_init_chip.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 133 133 dd->ipath_ibmaxlen, PCI_DMA_FROMDEVICE); 134 134 dd->ipath_f_put_tid(dd, e + (u64 __iomem *) 135 135 ((char __iomem *) dd->ipath_kregbase + 136 - dd->ipath_rcvegrbase), 0, 136 + dd->ipath_rcvegrbase), 137 + RCVHQ_RCV_TYPE_EAGER, 137 138 dd->ipath_port0_skbinfo[e].phys); 138 139 } 139 140 ··· 311 310 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_sendpiosize); 312 311 dd->ipath_piosize2k = val & ~0U; 313 312 dd->ipath_piosize4k = val >> 32; 314 - dd->ipath_ibmtu = 4096; /* default to largest legal MTU */ 313 + /* 314 + * Note: the chips support a maximum MTU of 4096, but the driver 315 + * hasn't implemented this feature yet, so set the initial value 316 + * to 2048. 317 + */ 318 + dd->ipath_ibmtu = 2048; 315 319 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_sendpiobufcnt); 316 320 dd->ipath_piobcnt2k = val & ~0U; 317 321 dd->ipath_piobcnt4k = val >> 32; ··· 345 339 dd->ipath_piobcnt2k, dd->ipath_pio2kbase); 346 340 347 341 spin_lock_init(&dd->ipath_tid_lock); 342 + 343 + spin_lock_init(&dd->ipath_gpio_lock); 344 + spin_lock_init(&dd->ipath_eep_st_lock); 345 + sema_init(&dd->ipath_eep_sem, 1); 348 346 349 347 done: 350 348 *pdp = pd; ··· 656 646 ret = dd->ipath_f_get_boardname(dd, boardn, sizeof boardn); 657 647 658 648 snprintf(dd->ipath_boardversion, sizeof(dd->ipath_boardversion), 659 - "Driver %u.%u, %s, InfiniPath%u %u.%u, PCI %u, " 649 + "ChipABI %u.%u, %s, InfiniPath%u %u.%u, PCI %u, " 660 650 "SW Compat %u\n", 661 651 IPATH_CHIP_VERS_MAJ, IPATH_CHIP_VERS_MIN, boardn, 662 652 (unsigned)(dd->ipath_revision >> INFINIPATH_R_ARCH_SHIFT) & ··· 737 727 uports = dd->ipath_cfgports ? dd->ipath_cfgports - 1 : 0; 738 728 if (ipath_kpiobufs == 0) { 739 729 /* not set by user (this is default) */ 740 - if (piobufs >= (uports * IPATH_MIN_USER_PORT_BUFCNT) + 32) 730 + if (piobufs > 144) 741 731 kpiobufs = 32; 742 732 else 743 733 kpiobufs = 16; ··· 777 767 piobufs, dd->ipath_pbufsport, uports); 778 768 779 769 dd->ipath_f_early_init(dd); 770 + /* 771 + * cancel any possible active sends from early driver load. 772 + * Follows early_init because some chips have to initialize 773 + * PIO buffers in early_init to avoid false parity errors. 774 + */ 775 + ipath_cancel_sends(dd); 780 776 781 777 /* early_init sets rcvhdrentsize and rcvhdrsize, so this must be 782 778 * done after early_init */
+124 -17
drivers/infiniband/hw/ipath/ipath_intr.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 93 93 94 94 if (sbuf[0] || sbuf[1] || (piobcnt > 128 && (sbuf[2] || sbuf[3]))) { 95 95 int i; 96 - if (ipath_debug & (__IPATH_PKTDBG|__IPATH_DBG)) { 96 + if (ipath_debug & (__IPATH_PKTDBG|__IPATH_DBG) && 97 + dd->ipath_lastcancel > jiffies) { 97 98 __IPATH_DBG_WHICH(__IPATH_PKTDBG|__IPATH_DBG, 98 99 "SendbufErrs %lx %lx", sbuf[0], 99 100 sbuf[1]); ··· 109 108 ipath_clrpiobuf(dd, i); 110 109 ipath_disarm_piobufs(dd, i, 1); 111 110 } 112 - dd->ipath_lastcancel = jiffies+3; /* no armlaunch for a bit */ 111 + /* ignore armlaunch errs for a bit */ 112 + dd->ipath_lastcancel = jiffies+3; 113 113 } 114 114 } 115 115 ··· 131 129 INFINIPATH_E_SMAXPKTLEN | INFINIPATH_E_SUNSUPVL | \ 132 130 INFINIPATH_E_SMINPKTLEN | INFINIPATH_E_SPKTLEN | \ 133 131 INFINIPATH_E_INVALIDADDR) 132 + 133 + /* 134 + * this is similar to E_SUM_ERRS, but can't ignore armlaunch, don't ignore 135 + * errors not related to freeze and cancelling buffers. Can't ignore 136 + * armlaunch because could get more while still cleaning up, and need 137 + * to cancel those as they happen. 138 + */ 139 + #define E_SPKT_ERRS_IGNORE \ 140 + (INFINIPATH_E_SDROPPEDDATAPKT | INFINIPATH_E_SDROPPEDSMPPKT | \ 141 + INFINIPATH_E_SMAXPKTLEN | INFINIPATH_E_SMINPKTLEN | \ 142 + INFINIPATH_E_SPKTLEN) 134 143 135 144 /* 136 145 * these are errors that can occur when the link changes state while ··· 303 290 * Flush all queued sends when link went to DOWN or INIT, 304 291 * to be sure that they don't block SMA and other MAD packets 305 292 */ 306 - ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 307 - INFINIPATH_S_ABORT); 308 - ipath_disarm_piobufs(dd, dd->ipath_lastport_piobuf, 309 - (unsigned)(dd->ipath_piobcnt2k + 310 - dd->ipath_piobcnt4k) - 311 - dd->ipath_lastport_piobuf); 293 + ipath_cancel_sends(dd); 312 294 } 313 295 else if (lstate == IPATH_IBSTATE_INIT || lstate == IPATH_IBSTATE_ARM || 314 296 lstate == IPATH_IBSTATE_ACTIVE) { ··· 513 505 int i, iserr = 0; 514 506 int chkerrpkts = 0, noprint = 0; 515 507 unsigned supp_msgs; 508 + int log_idx; 516 509 517 510 supp_msgs = handle_frequent_errors(dd, errs, msg, &noprint); 518 511 ··· 527 518 if (errs & INFINIPATH_E_HARDWARE) { 528 519 /* reuse same msg buf */ 529 520 dd->ipath_f_handle_hwerrors(dd, msg, sizeof msg); 521 + } else { 522 + u64 mask; 523 + for (log_idx = 0; log_idx < IPATH_EEP_LOG_CNT; ++log_idx) { 524 + mask = dd->ipath_eep_st_masks[log_idx].errs_to_log; 525 + if (errs & mask) 526 + ipath_inc_eeprom_err(dd, log_idx, 1); 527 + } 530 528 } 531 529 532 530 if (!noprint && (errs & ~dd->ipath_e_bitsextant)) ··· 691 675 chkerrpkts = 1; 692 676 dd->ipath_lastrcvhdrqtails[i] = tl; 693 677 pd->port_hdrqfull++; 678 + if (test_bit(IPATH_PORT_WAITING_OVERFLOW, 679 + &pd->port_flag)) { 680 + clear_bit( 681 + IPATH_PORT_WAITING_OVERFLOW, 682 + &pd->port_flag); 683 + set_bit( 684 + IPATH_PORT_WAITING_OVERFLOW, 685 + &pd->int_flag); 686 + wake_up_interruptible( 687 + &pd->port_wait); 688 + } 694 689 } 695 690 } 696 691 } ··· 770 743 771 744 return chkerrpkts; 772 745 } 746 + 747 + 748 + /* 749 + * try to cleanup as much as possible for anything that might have gone 750 + * wrong while in freeze mode, such as pio buffers being written by user 751 + * processes (causing armlaunch), send errors due to going into freeze mode, 752 + * etc., and try to avoid causing extra interrupts while doing so. 753 + * Forcibly update the in-memory pioavail register copies after cleanup 754 + * because the chip won't do it for anything changing while in freeze mode 755 + * (we don't want to wait for the next pio buffer state change). 756 + * Make sure that we don't lose any important interrupts by using the chip 757 + * feature that says that writing 0 to a bit in *clear that is set in 758 + * *status will cause an interrupt to be generated again (if allowed by 759 + * the *mask value). 760 + */ 761 + void ipath_clear_freeze(struct ipath_devdata *dd) 762 + { 763 + int i, im; 764 + __le64 val; 765 + 766 + /* disable error interrupts, to avoid confusion */ 767 + ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 0ULL); 768 + 769 + /* 770 + * clear all sends, because they have may been 771 + * completed by usercode while in freeze mode, and 772 + * therefore would not be sent, and eventually 773 + * might cause the process to run out of bufs 774 + */ 775 + ipath_cancel_sends(dd); 776 + ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 777 + dd->ipath_control); 778 + 779 + /* ensure pio avail updates continue */ 780 + ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 781 + dd->ipath_sendctrl & ~IPATH_S_PIOBUFAVAILUPD); 782 + ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 783 + ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 784 + dd->ipath_sendctrl); 785 + 786 + /* 787 + * We just enabled pioavailupdate, so dma copy is almost certainly 788 + * not yet right, so read the registers directly. Similar to init 789 + */ 790 + for (i = 0; i < dd->ipath_pioavregs; i++) { 791 + /* deal with 6110 chip bug */ 792 + im = i > 3 ? ((i&1) ? i-1 : i+1) : i; 793 + val = ipath_read_kreg64(dd, 0x1000+(im*sizeof(u64))); 794 + dd->ipath_pioavailregs_dma[i] = dd->ipath_pioavailshadow[i] 795 + = le64_to_cpu(val); 796 + } 797 + 798 + /* 799 + * force new interrupt if any hwerr, error or interrupt bits are 800 + * still set, and clear "safe" send packet errors related to freeze 801 + * and cancelling sends. Re-enable error interrupts before possible 802 + * force of re-interrupt on pending interrupts. 803 + */ 804 + ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear, 0ULL); 805 + ipath_write_kreg(dd, dd->ipath_kregs->kr_errorclear, 806 + E_SPKT_ERRS_IGNORE); 807 + ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 808 + ~dd->ipath_maskederrs); 809 + ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, 0ULL); 810 + } 811 + 773 812 774 813 /* this is separate to allow for better optimization of ipath_intr() */ 775 814 ··· 965 872 dd->ipath_i_rcvurg_mask); 966 873 for (i = 1; i < dd->ipath_cfgports; i++) { 967 874 struct ipath_portdata *pd = dd->ipath_pd[i]; 968 - if (portr & (1 << i) && pd && pd->port_cnt && 969 - test_bit(IPATH_PORT_WAITING_RCV, &pd->port_flag)) { 970 - clear_bit(IPATH_PORT_WAITING_RCV, 971 - &pd->port_flag); 972 - clear_bit(i + INFINIPATH_R_INTRAVAIL_SHIFT, 973 - &dd->ipath_rcvctrl); 974 - wake_up_interruptible(&pd->port_wait); 975 - rcvdint = 1; 875 + if (portr & (1 << i) && pd && pd->port_cnt) { 876 + if (test_bit(IPATH_PORT_WAITING_RCV, 877 + &pd->port_flag)) { 878 + clear_bit(IPATH_PORT_WAITING_RCV, 879 + &pd->port_flag); 880 + set_bit(IPATH_PORT_WAITING_RCV, 881 + &pd->int_flag); 882 + clear_bit(i + INFINIPATH_R_INTRAVAIL_SHIFT, 883 + &dd->ipath_rcvctrl); 884 + wake_up_interruptible(&pd->port_wait); 885 + rcvdint = 1; 886 + } else if (test_bit(IPATH_PORT_WAITING_URG, 887 + &pd->port_flag)) { 888 + clear_bit(IPATH_PORT_WAITING_URG, 889 + &pd->port_flag); 890 + set_bit(IPATH_PORT_WAITING_URG, 891 + &pd->int_flag); 892 + wake_up_interruptible(&pd->port_wait); 893 + } 976 894 } 977 895 } 978 896 if (rcvdint) { ··· 1008 904 (1U<<INFINIPATH_I_RCVURG_SHIFT); 1009 905 1010 906 ipath_stats.sps_ints++; 907 + 908 + if (dd->ipath_int_counter != (u32) -1) 909 + dd->ipath_int_counter++; 1011 910 1012 911 if (!(dd->ipath_flags & IPATH_PRESENT)) { 1013 912 /*
+78 -7
drivers/infiniband/hw/ipath/ipath_kernel.h
··· 1 1 #ifndef _IPATH_KERNEL_H 2 2 #define _IPATH_KERNEL_H 3 3 /* 4 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 4 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 5 5 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 6 6 * 7 7 * This software is available to you under a choice of one of two ··· 57 57 extern struct infinipath_stats ipath_stats; 58 58 59 59 #define IPATH_CHIP_SWVERSION IPATH_CHIP_VERS_MAJ 60 + /* 61 + * First-cut critierion for "device is active" is 62 + * two thousand dwords combined Tx, Rx traffic per 63 + * 5-second interval. SMA packets are 64 dwords, 64 + * and occur "a few per second", presumably each way. 65 + */ 66 + #define IPATH_TRAFFIC_ACTIVE_THRESHOLD (2000) 67 + /* 68 + * Struct used to indicate which errors are logged in each of the 69 + * error-counters that are logged to EEPROM. A counter is incremented 70 + * _once_ (saturating at 255) for each event with any bits set in 71 + * the error or hwerror register masks below. 72 + */ 73 + #define IPATH_EEP_LOG_CNT (4) 74 + struct ipath_eep_log_mask { 75 + u64 errs_to_log; 76 + u64 hwerrs_to_log; 77 + }; 60 78 61 79 struct ipath_portdata { 62 80 void **port_rcvegrbuf; ··· 127 109 u32 port_tidcursor; 128 110 /* next expected TID to check */ 129 111 unsigned long port_flag; 112 + /* what happened */ 113 + unsigned long int_flag; 130 114 /* WAIT_RCV that timed out, no interrupt */ 131 115 u32 port_rcvwait_to; 132 116 /* WAIT_PIO that timed out, no interrupt */ ··· 157 137 u32 userversion; 158 138 /* Bitmask of active slaves */ 159 139 u32 active_slaves; 140 + /* Type of packets or conditions we want to poll for */ 141 + u16 poll_type; 160 142 }; 161 143 162 144 struct sk_buff; ··· 297 275 u32 ipath_lastport_piobuf; 298 276 /* is a stats timer active */ 299 277 u32 ipath_stats_timer_active; 278 + /* number of interrupts for this device -- saturates... */ 279 + u32 ipath_int_counter; 300 280 /* dwords sent read from counter */ 301 281 u32 ipath_lastsword; 302 282 /* dwords received read from counter */ ··· 393 369 struct class_device *diag_class_dev; 394 370 /* timer used to prevent stats overflow, error throttling, etc. */ 395 371 struct timer_list ipath_stats_timer; 396 - /* check for stale messages in rcv queue */ 397 - /* only allow one intr at a time. */ 398 - unsigned long ipath_rcv_pending; 399 372 void *ipath_dummy_hdrq; /* used after port close */ 400 373 dma_addr_t ipath_dummy_hdrq_phys; 401 374 ··· 420 399 u64 ipath_gpio_out; 421 400 /* shadow the gpio mask register */ 422 401 u64 ipath_gpio_mask; 402 + /* shadow the gpio output enable, etc... */ 403 + u64 ipath_extctrl; 423 404 /* kr_revision shadow */ 424 405 u64 ipath_revision; 425 406 /* ··· 496 473 u32 ipath_cregbase; 497 474 /* shadow the control register contents */ 498 475 u32 ipath_control; 499 - /* shadow the gpio output contents */ 500 - u32 ipath_extctrl; 501 476 /* PCI revision register (HTC rev on FPGA) */ 502 477 u32 ipath_pcirev; 503 478 ··· 573 552 u32 ipath_overrun_thresh_errs; 574 553 u32 ipath_lli_errs; 575 554 555 + /* status check work */ 556 + struct delayed_work status_work; 557 + 576 558 /* 577 559 * Not all devices managed by a driver instance are the same 578 560 * type, so these fields must be per-device. ··· 599 575 u16 ipath_gpio_scl_num; 600 576 u64 ipath_gpio_sda; 601 577 u64 ipath_gpio_scl; 578 + 579 + /* lock for doing RMW of shadows/regs for ExtCtrl and GPIO */ 580 + spinlock_t ipath_gpio_lock; 581 + 582 + /* used to override LED behavior */ 583 + u8 ipath_led_override; /* Substituted for normal value, if non-zero */ 584 + u16 ipath_led_override_timeoff; /* delta to next timer event */ 585 + u8 ipath_led_override_vals[2]; /* Alternates per blink-frame */ 586 + u8 ipath_led_override_phase; /* Just counts, LSB picks from vals[] */ 587 + atomic_t ipath_led_override_timer_active; 588 + /* Used to flash LEDs in override mode */ 589 + struct timer_list ipath_led_override_timer; 590 + 591 + /* Support (including locks) for EEPROM logging of errors and time */ 592 + /* control access to actual counters, timer */ 593 + spinlock_t ipath_eep_st_lock; 594 + /* control high-level access to EEPROM */ 595 + struct semaphore ipath_eep_sem; 596 + /* Below inc'd by ipath_snap_cntrs(), locked by ipath_eep_st_lock */ 597 + uint64_t ipath_traffic_wds; 598 + /* active time is kept in seconds, but logged in hours */ 599 + atomic_t ipath_active_time; 600 + /* Below are nominal shadow of EEPROM, new since last EEPROM update */ 601 + uint8_t ipath_eep_st_errs[IPATH_EEP_LOG_CNT]; 602 + uint8_t ipath_eep_st_new_errs[IPATH_EEP_LOG_CNT]; 603 + uint16_t ipath_eep_hrs; 604 + /* 605 + * masks for which bits of errs, hwerrs that cause 606 + * each of the counters to increment. 607 + */ 608 + struct ipath_eep_log_mask ipath_eep_st_masks[IPATH_EEP_LOG_CNT]; 602 609 }; 603 610 604 611 /* Private data for file operations */ ··· 647 592 void ipath_disable_wc(struct ipath_devdata *dd); 648 593 int ipath_count_units(int *npresentp, int *nupp, u32 *maxportsp); 649 594 void ipath_shutdown_device(struct ipath_devdata *); 595 + void ipath_clear_freeze(struct ipath_devdata *); 650 596 651 597 struct file_operations; 652 598 int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, ··· 683 627 684 628 void ipath_disarm_piobufs(struct ipath_devdata *, unsigned first, 685 629 unsigned cnt); 630 + void ipath_cancel_sends(struct ipath_devdata *); 686 631 687 632 int ipath_create_rcvhdrq(struct ipath_devdata *, struct ipath_portdata *); 688 633 void ipath_free_pddata(struct ipath_devdata *, struct ipath_portdata *); ··· 742 685 * are 64bit */ 743 686 #define IPATH_32BITCOUNTERS 0x20000 744 687 /* can miss port0 rx interrupts */ 745 - #define IPATH_POLL_RX_INTR 0x40000 746 688 #define IPATH_DISABLED 0x80000 /* administratively disabled */ 747 689 /* Use GPIO interrupts for new counters */ 748 690 #define IPATH_GPIO_ERRINTRS 0x100000 ··· 760 704 #define IPATH_PORT_WAITING_PIO 3 761 705 /* master has not finished initializing */ 762 706 #define IPATH_PORT_MASTER_UNINIT 4 707 + /* waiting for an urgent packet to arrive */ 708 + #define IPATH_PORT_WAITING_URG 5 709 + /* waiting for a header overflow */ 710 + #define IPATH_PORT_WAITING_OVERFLOW 6 763 711 764 712 /* free up any allocated data at closes */ 765 713 void ipath_free_data(struct ipath_portdata *dd); ··· 773 713 void ipath_init_iba6120_funcs(struct ipath_devdata *); 774 714 void ipath_init_iba6110_funcs(struct ipath_devdata *); 775 715 void ipath_get_eeprom_info(struct ipath_devdata *); 716 + int ipath_update_eeprom_log(struct ipath_devdata *dd); 717 + void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr); 776 718 u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg); 777 719 void ipath_disarm_senderrbufs(struct ipath_devdata *, int); 720 + 721 + /* 722 + * Set LED override, only the two LSBs have "public" meaning, but 723 + * any non-zero value substitutes them for the Link and LinkTrain 724 + * LED states. 725 + */ 726 + #define IPATH_LED_PHYS 1 /* Physical (linktraining) GREEN LED */ 727 + #define IPATH_LED_LOG 2 /* Logical (link) YELLOW LED */ 728 + void ipath_set_led_override(struct ipath_devdata *dd, unsigned int val); 778 729 779 730 /* 780 731 * number of words used for protocol header if not set by ipath_userinit();
+1 -1
drivers/infiniband/hw/ipath/ipath_keys.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+1 -1
drivers/infiniband/hw/ipath/ipath_layer.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+1 -1
drivers/infiniband/hw/ipath/ipath_layer.h
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+8 -3
drivers/infiniband/hw/ipath/ipath_mad.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 103 103 /* This is already in network order */ 104 104 nip->sys_guid = to_idev(ibdev)->sys_image_guid; 105 105 nip->node_guid = dd->ipath_guid; 106 - nip->port_guid = nip->sys_guid; 106 + nip->port_guid = dd->ipath_guid; 107 107 nip->partition_cap = cpu_to_be16(ipath_get_npkeys(dd)); 108 108 nip->device_id = cpu_to_be16(dd->ipath_deviceid); 109 109 majrev = dd->ipath_majrev; ··· 292 292 /* pip->vl_arb_high_cap; // only one VL */ 293 293 /* pip->vl_arb_low_cap; // only one VL */ 294 294 /* InitTypeReply = 0 */ 295 - pip->inittypereply_mtucap = IB_MTU_4096; 295 + /* 296 + * Note: the chips support a maximum MTU of 4096, but the driver 297 + * hasn't implemented this feature yet, so set the maximum value 298 + * to 2048. 299 + */ 300 + pip->inittypereply_mtucap = IB_MTU_2048; 296 301 // HCAs ignore VLStallCount and HOQLife 297 302 /* pip->vlstallcnt_hoqlife; */ 298 303 pip->operationalvl_pei_peo_fpi_fpo = 0x10; /* OVLs = 1 */
+1 -1
drivers/infiniband/hw/ipath/ipath_mmap.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * 4 4 * This software is available to you under a choice of one of two 5 5 * licenses. You may choose to be licensed under the terms of the GNU
+1 -1
drivers/infiniband/hw/ipath/ipath_mr.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+8 -11
drivers/infiniband/hw/ipath/ipath_qp.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 336 336 qp->qkey = 0; 337 337 qp->qp_access_flags = 0; 338 338 qp->s_busy = 0; 339 - qp->s_flags &= ~IPATH_S_SIGNAL_REQ_WR; 339 + qp->s_flags &= IPATH_S_SIGNAL_REQ_WR; 340 340 qp->s_hdrwords = 0; 341 341 qp->s_psn = 0; 342 342 qp->r_psn = 0; ··· 507 507 attr->port_num > ibqp->device->phys_port_cnt) 508 508 goto inval; 509 509 510 + /* 511 + * Note: the chips support a maximum MTU of 4096, but the driver 512 + * hasn't implemented this feature yet, so don't allow Path MTU 513 + * values greater than 2048. 514 + */ 510 515 if (attr_mask & IB_QP_PATH_MTU) 511 - if (attr->path_mtu > IB_MTU_4096) 512 - goto inval; 513 - 514 - if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) 515 - if (attr->max_dest_rd_atomic > 1) 516 - goto inval; 517 - 518 - if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) 519 - if (attr->max_rd_atomic > 1) 516 + if (attr->path_mtu > IB_MTU_2048) 520 517 goto inval; 521 518 522 519 if (attr_mask & IB_QP_PATH_MIG_STATE)
+82 -34
drivers/infiniband/hw/ipath/ipath_rc.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 125 125 if (len > pmtu) { 126 126 len = pmtu; 127 127 qp->s_ack_state = OP(RDMA_READ_RESPONSE_FIRST); 128 - } else 128 + } else { 129 129 qp->s_ack_state = OP(RDMA_READ_RESPONSE_ONLY); 130 + e->sent = 1; 131 + } 130 132 ohdr->u.aeth = ipath_compute_aeth(qp); 131 133 hwords++; 132 134 qp->s_ack_rdma_psn = e->psn; ··· 145 143 cpu_to_be32(e->atomic_data); 146 144 hwords += sizeof(ohdr->u.at) / sizeof(u32); 147 145 bth2 = e->psn; 146 + e->sent = 1; 148 147 } 149 148 bth0 = qp->s_ack_state << 24; 150 149 break; ··· 161 158 ohdr->u.aeth = ipath_compute_aeth(qp); 162 159 hwords++; 163 160 qp->s_ack_state = OP(RDMA_READ_RESPONSE_LAST); 161 + qp->s_ack_queue[qp->s_tail_ack_queue].sent = 1; 164 162 } 165 163 bth0 = qp->s_ack_state << 24; 166 164 bth2 = qp->s_ack_rdma_psn++ & IPATH_PSN_MASK; ··· 192 188 } 193 189 qp->s_hdrwords = hwords; 194 190 qp->s_cur_size = len; 195 - *bth0p = bth0; 191 + *bth0p = bth0 | (1 << 22); /* Set M bit */ 196 192 *bth2p = bth2; 197 193 return 1; 198 194 ··· 244 240 245 241 /* header size in 32-bit words LRH+BTH = (8+12)/4. */ 246 242 hwords = 5; 247 - bth0 = 0; 243 + bth0 = 1 << 22; /* Set M bit */ 248 244 249 245 /* Send a request. */ 250 246 wqe = get_swqe_ptr(qp, qp->s_cur); ··· 608 604 } 609 605 /* read pkey_index w/o lock (its atomic) */ 610 606 bth0 = ipath_get_pkey(dev->dd, qp->s_pkey_index) | 611 - OP(ACKNOWLEDGE) << 24; 607 + (OP(ACKNOWLEDGE) << 24) | (1 << 22); 612 608 if (qp->r_nak_state) 613 609 ohdr->u.aeth = cpu_to_be32((qp->r_msn & IPATH_MSN_MASK) | 614 610 (qp->r_nak_state << ··· 810 806 * Called at interrupt level with the QP s_lock held and interrupts disabled. 811 807 * Returns 1 if OK, 0 if current operation should be aborted (NAK). 812 808 */ 813 - static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode) 809 + static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode, 810 + u64 val) 814 811 { 815 812 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 816 813 struct ib_wc wc; 817 814 struct ipath_swqe *wqe; 818 815 int ret = 0; 819 816 u32 ack_psn; 817 + int diff; 820 818 821 819 /* 822 820 * Remove the QP from the timeout queue (or RNR timeout queue). ··· 846 840 * The MSN might be for a later WQE than the PSN indicates so 847 841 * only complete WQEs that the PSN finishes. 848 842 */ 849 - while (ipath_cmp24(ack_psn, wqe->lpsn) >= 0) { 843 + while ((diff = ipath_cmp24(ack_psn, wqe->lpsn)) >= 0) { 844 + /* 845 + * RDMA_READ_RESPONSE_ONLY is a special case since 846 + * we want to generate completion events for everything 847 + * before the RDMA read, copy the data, then generate 848 + * the completion for the read. 849 + */ 850 + if (wqe->wr.opcode == IB_WR_RDMA_READ && 851 + opcode == OP(RDMA_READ_RESPONSE_ONLY) && 852 + diff == 0) { 853 + ret = 1; 854 + goto bail; 855 + } 850 856 /* 851 857 * If this request is a RDMA read or atomic, and the ACK is 852 858 * for a later operation, this ACK NAKs the RDMA read or ··· 869 851 * is sent but before the response is received. 870 852 */ 871 853 if ((wqe->wr.opcode == IB_WR_RDMA_READ && 872 - (opcode != OP(RDMA_READ_RESPONSE_LAST) || 873 - ipath_cmp24(ack_psn, wqe->lpsn) != 0)) || 854 + (opcode != OP(RDMA_READ_RESPONSE_LAST) || diff != 0)) || 874 855 ((wqe->wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP || 875 856 wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) && 876 - (opcode != OP(ATOMIC_ACKNOWLEDGE) || 877 - ipath_cmp24(wqe->psn, psn) != 0))) { 857 + (opcode != OP(ATOMIC_ACKNOWLEDGE) || diff != 0))) { 878 858 /* 879 859 * The last valid PSN seen is the previous 880 860 * request's. ··· 886 870 */ 887 871 goto bail; 888 872 } 873 + if (wqe->wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP || 874 + wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) 875 + *(u64 *) wqe->sg_list[0].vaddr = val; 889 876 if (qp->s_num_rd_atomic && 890 877 (wqe->wr.opcode == IB_WR_RDMA_READ || 891 878 wqe->wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP || ··· 1098 1079 int diff; 1099 1080 u32 pad; 1100 1081 u32 aeth; 1082 + u64 val; 1101 1083 1102 1084 spin_lock_irqsave(&qp->s_lock, flags); 1103 1085 ··· 1138 1118 data += sizeof(__be32); 1139 1119 } 1140 1120 if (opcode == OP(ATOMIC_ACKNOWLEDGE)) { 1141 - u64 val; 1142 - 1143 1121 if (!header_in_data) { 1144 1122 __be32 *p = ohdr->u.at.atomic_ack_eth; 1145 1123 ··· 1145 1127 be32_to_cpu(p[1]); 1146 1128 } else 1147 1129 val = be64_to_cpu(((__be64 *) data)[0]); 1148 - *(u64 *) wqe->sg_list[0].vaddr = val; 1149 - } 1150 - if (!do_rc_ack(qp, aeth, psn, opcode) || 1130 + } else 1131 + val = 0; 1132 + if (!do_rc_ack(qp, aeth, psn, opcode, val) || 1151 1133 opcode != OP(RDMA_READ_RESPONSE_FIRST)) 1152 1134 goto ack_done; 1153 1135 hdrsize += 4; 1136 + wqe = get_swqe_ptr(qp, qp->s_last); 1154 1137 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1155 1138 goto ack_op_err; 1156 1139 /* ··· 1195 1176 goto bail; 1196 1177 1197 1178 case OP(RDMA_READ_RESPONSE_ONLY): 1198 - if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) { 1199 - dev->n_rdma_seq++; 1200 - ipath_restart_rc(qp, qp->s_last_psn + 1, &wc); 1179 + if (!header_in_data) 1180 + aeth = be32_to_cpu(ohdr->u.aeth); 1181 + else 1182 + aeth = be32_to_cpu(((__be32 *) data)[0]); 1183 + if (!do_rc_ack(qp, aeth, psn, opcode, 0)) 1201 1184 goto ack_done; 1202 - } 1203 - if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1204 - goto ack_op_err; 1205 1185 /* Get the number of bytes the message was padded by. */ 1206 1186 pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3; 1207 1187 /* ··· 1215 1197 * have to be careful to copy the data to the right 1216 1198 * location. 1217 1199 */ 1200 + wqe = get_swqe_ptr(qp, qp->s_last); 1218 1201 qp->s_rdma_read_len = restart_sge(&qp->s_rdma_read_sge, 1219 1202 wqe, psn, pmtu); 1220 1203 goto read_last; ··· 1249 1230 data += sizeof(__be32); 1250 1231 } 1251 1232 ipath_copy_sge(&qp->s_rdma_read_sge, data, tlen); 1252 - (void) do_rc_ack(qp, aeth, psn, OP(RDMA_READ_RESPONSE_LAST)); 1233 + (void) do_rc_ack(qp, aeth, psn, 1234 + OP(RDMA_READ_RESPONSE_LAST), 0); 1253 1235 goto ack_done; 1254 1236 } 1255 1237 ··· 1364 1344 e = NULL; 1365 1345 break; 1366 1346 } 1367 - if (ipath_cmp24(psn, e->psn) >= 0) 1347 + if (ipath_cmp24(psn, e->psn) >= 0) { 1348 + if (prev == qp->s_tail_ack_queue) 1349 + old_req = 0; 1368 1350 break; 1351 + } 1369 1352 } 1370 1353 switch (opcode) { 1371 1354 case OP(RDMA_READ_REQUEST): { ··· 1480 1457 spin_lock_irqsave(&qp->s_lock, flags); 1481 1458 qp->state = IB_QPS_ERR; 1482 1459 ipath_error_qp(qp, err); 1460 + spin_unlock_irqrestore(&qp->s_lock, flags); 1461 + } 1462 + 1463 + static inline void ipath_update_ack_queue(struct ipath_qp *qp, unsigned n) 1464 + { 1465 + unsigned long flags; 1466 + unsigned next; 1467 + 1468 + next = n + 1; 1469 + if (next > IPATH_MAX_RDMA_ATOMIC) 1470 + next = 0; 1471 + spin_lock_irqsave(&qp->s_lock, flags); 1472 + if (n == qp->s_tail_ack_queue) { 1473 + qp->s_tail_ack_queue = next; 1474 + qp->s_ack_state = OP(ACKNOWLEDGE); 1475 + } 1483 1476 spin_unlock_irqrestore(&qp->s_lock, flags); 1484 1477 } 1485 1478 ··· 1711 1672 case OP(RDMA_WRITE_FIRST): 1712 1673 case OP(RDMA_WRITE_ONLY): 1713 1674 case OP(RDMA_WRITE_ONLY_WITH_IMMEDIATE): 1675 + if (unlikely(!(qp->qp_access_flags & 1676 + IB_ACCESS_REMOTE_WRITE))) 1677 + goto nack_inv; 1714 1678 /* consume RWQE */ 1715 1679 /* RETH comes after BTH */ 1716 1680 if (!header_in_data) ··· 1743 1701 qp->r_sge.sge.length = 0; 1744 1702 qp->r_sge.sge.sge_length = 0; 1745 1703 } 1746 - if (unlikely(!(qp->qp_access_flags & 1747 - IB_ACCESS_REMOTE_WRITE))) 1748 - goto nack_acc; 1749 1704 if (opcode == OP(RDMA_WRITE_FIRST)) 1750 1705 goto send_middle; 1751 1706 else if (opcode == OP(RDMA_WRITE_ONLY)) ··· 1756 1717 u32 len; 1757 1718 u8 next; 1758 1719 1759 - if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_READ))) 1760 - goto nack_acc; 1720 + if (unlikely(!(qp->qp_access_flags & 1721 + IB_ACCESS_REMOTE_READ))) 1722 + goto nack_inv; 1761 1723 next = qp->r_head_ack_queue + 1; 1762 1724 if (next > IPATH_MAX_RDMA_ATOMIC) 1763 1725 next = 0; 1764 - if (unlikely(next == qp->s_tail_ack_queue)) 1765 - goto nack_inv; 1726 + if (unlikely(next == qp->s_tail_ack_queue)) { 1727 + if (!qp->s_ack_queue[next].sent) 1728 + goto nack_inv; 1729 + ipath_update_ack_queue(qp, next); 1730 + } 1766 1731 e = &qp->s_ack_queue[qp->r_head_ack_queue]; 1767 1732 /* RETH comes after BTH */ 1768 1733 if (!header_in_data) ··· 1801 1758 e->rdma_sge.sge.sge_length = 0; 1802 1759 } 1803 1760 e->opcode = opcode; 1761 + e->sent = 0; 1804 1762 e->psn = psn; 1805 1763 /* 1806 1764 * We need to increment the MSN here instead of when we ··· 1833 1789 1834 1790 if (unlikely(!(qp->qp_access_flags & 1835 1791 IB_ACCESS_REMOTE_ATOMIC))) 1836 - goto nack_acc; 1792 + goto nack_inv; 1837 1793 next = qp->r_head_ack_queue + 1; 1838 1794 if (next > IPATH_MAX_RDMA_ATOMIC) 1839 1795 next = 0; 1840 - if (unlikely(next == qp->s_tail_ack_queue)) 1841 - goto nack_inv; 1796 + if (unlikely(next == qp->s_tail_ack_queue)) { 1797 + if (!qp->s_ack_queue[next].sent) 1798 + goto nack_inv; 1799 + ipath_update_ack_queue(qp, next); 1800 + } 1842 1801 if (!header_in_data) 1843 1802 ateth = &ohdr->u.atomic_eth; 1844 1803 else ··· 1866 1819 be64_to_cpu(ateth->compare_data), 1867 1820 sdata); 1868 1821 e->opcode = opcode; 1822 + e->sent = 0; 1869 1823 e->psn = psn & IPATH_PSN_MASK; 1870 1824 qp->r_msn++; 1871 1825 qp->r_psn++;
+1 -1
drivers/infiniband/hw/ipath/ipath_registers.h
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+26 -10
drivers/infiniband/hw/ipath/ipath_ruc.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 194 194 ret = 0; 195 195 goto bail; 196 196 } 197 + /* Make sure entry is read after head index is read. */ 198 + smp_rmb(); 197 199 wqe = get_rwqe_ptr(rq, tail); 198 200 if (++tail >= rq->size) 199 201 tail = 0; ··· 269 267 spin_lock_irqsave(&sqp->s_lock, flags); 270 268 271 269 if (!(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_SEND_OK) || 272 - qp->s_rnr_timeout) { 270 + sqp->s_rnr_timeout) { 273 271 spin_unlock_irqrestore(&sqp->s_lock, flags); 274 272 goto done; 275 273 } ··· 321 319 break; 322 320 323 321 case IB_WR_RDMA_WRITE_WITH_IMM: 322 + if (unlikely(!(qp->qp_access_flags & 323 + IB_ACCESS_REMOTE_WRITE))) { 324 + wc.status = IB_WC_REM_INV_REQ_ERR; 325 + goto err; 326 + } 324 327 wc.wc_flags = IB_WC_WITH_IMM; 325 328 wc.imm_data = wqe->wr.imm_data; 326 329 if (!ipath_get_rwqe(qp, 1)) 327 330 goto rnr_nak; 328 331 /* FALLTHROUGH */ 329 332 case IB_WR_RDMA_WRITE: 333 + if (unlikely(!(qp->qp_access_flags & 334 + IB_ACCESS_REMOTE_WRITE))) { 335 + wc.status = IB_WC_REM_INV_REQ_ERR; 336 + goto err; 337 + } 330 338 if (wqe->length == 0) 331 339 break; 332 340 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, wqe->length, ··· 366 354 367 355 case IB_WR_RDMA_READ: 368 356 if (unlikely(!(qp->qp_access_flags & 369 - IB_ACCESS_REMOTE_READ))) 370 - goto acc_err; 357 + IB_ACCESS_REMOTE_READ))) { 358 + wc.status = IB_WC_REM_INV_REQ_ERR; 359 + goto err; 360 + } 371 361 if (unlikely(!ipath_rkey_ok(qp, &sqp->s_sge, wqe->length, 372 362 wqe->wr.wr.rdma.remote_addr, 373 363 wqe->wr.wr.rdma.rkey, ··· 383 369 case IB_WR_ATOMIC_CMP_AND_SWP: 384 370 case IB_WR_ATOMIC_FETCH_AND_ADD: 385 371 if (unlikely(!(qp->qp_access_flags & 386 - IB_ACCESS_REMOTE_ATOMIC))) 387 - goto acc_err; 372 + IB_ACCESS_REMOTE_ATOMIC))) { 373 + wc.status = IB_WC_REM_INV_REQ_ERR; 374 + goto err; 375 + } 388 376 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, sizeof(u64), 389 377 wqe->wr.wr.atomic.remote_addr, 390 378 wqe->wr.wr.atomic.rkey, ··· 412 396 413 397 if (len > sge->length) 414 398 len = sge->length; 399 + if (len > sge->sge_length) 400 + len = sge->sge_length; 415 401 BUG_ON(len == 0); 416 402 ipath_copy_sge(&qp->r_sge, sge->vaddr, len); 417 403 sge->vaddr += len; ··· 521 503 * could be called. If we are still in the tasklet function, 522 504 * tasklet_hi_schedule() will not call us until the next time 523 505 * tasklet_hi_schedule() is called. 524 - * We clear the tasklet flag now since we are committing to return 525 - * from the tasklet function. 506 + * We leave the busy flag set so that another post send doesn't 507 + * try to put the same QP on the piowait list again. 526 508 */ 527 - clear_bit(IPATH_S_BUSY, &qp->s_busy); 528 - tasklet_unlock(&qp->s_task); 529 509 want_buffer(dev->dd); 530 510 dev->n_piowait++; 531 511 }
+3 -1
drivers/infiniband/hw/ipath/ipath_srq.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 80 80 wqe->num_sge = wr->num_sge; 81 81 for (i = 0; i < wr->num_sge; i++) 82 82 wqe->sg_list[i] = wr->sg_list[i]; 83 + /* Make sure queue entry is written before the head index. */ 84 + smp_wmb(); 83 85 wq->head = next; 84 86 spin_unlock_irqrestore(&srq->rq.lock, flags); 85 87 }
+22 -3
drivers/infiniband/hw/ipath/ipath_stats.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 55 55 u64 val64; 56 56 unsigned long t0, t1; 57 57 u64 ret; 58 + unsigned long flags; 58 59 59 60 t0 = jiffies; 60 61 /* If fast increment counters are only 32 bits, snapshot them, ··· 92 91 if (creg == dd->ipath_cregs->cr_wordsendcnt) { 93 92 if (val != dd->ipath_lastsword) { 94 93 dd->ipath_sword += val - dd->ipath_lastsword; 94 + spin_lock_irqsave(&dd->ipath_eep_st_lock, flags); 95 + dd->ipath_traffic_wds += val - dd->ipath_lastsword; 96 + spin_unlock_irqrestore(&dd->ipath_eep_st_lock, flags); 95 97 dd->ipath_lastsword = val; 96 98 } 97 99 val64 = dd->ipath_sword; 98 100 } else if (creg == dd->ipath_cregs->cr_wordrcvcnt) { 99 101 if (val != dd->ipath_lastrword) { 100 102 dd->ipath_rword += val - dd->ipath_lastrword; 103 + spin_lock_irqsave(&dd->ipath_eep_st_lock, flags); 104 + dd->ipath_traffic_wds += val - dd->ipath_lastrword; 105 + spin_unlock_irqrestore(&dd->ipath_eep_st_lock, flags); 101 106 dd->ipath_lastrword = val; 102 107 } 103 108 val64 = dd->ipath_rword; ··· 207 200 struct ipath_devdata *dd = (struct ipath_devdata *) opaque; 208 201 u32 val; 209 202 static unsigned cnt; 203 + unsigned long flags; 210 204 211 205 /* 212 206 * don't access the chip while running diags, or memory diags can ··· 218 210 /* but re-arm the timer, for diags case; won't hurt other */ 219 211 goto done; 220 212 213 + /* 214 + * We now try to maintain a "active timer", based on traffic 215 + * exceeding a threshold, so we need to check the word-counts 216 + * even if they are 64-bit. 217 + */ 218 + ipath_snap_cntr(dd, dd->ipath_cregs->cr_wordsendcnt); 219 + ipath_snap_cntr(dd, dd->ipath_cregs->cr_wordrcvcnt); 220 + spin_lock_irqsave(&dd->ipath_eep_st_lock, flags); 221 + if (dd->ipath_traffic_wds >= IPATH_TRAFFIC_ACTIVE_THRESHOLD) 222 + atomic_add(5, &dd->ipath_active_time); /* S/B #define */ 223 + dd->ipath_traffic_wds = 0; 224 + spin_unlock_irqrestore(&dd->ipath_eep_st_lock, flags); 225 + 221 226 if (dd->ipath_flags & IPATH_32BITCOUNTERS) { 222 - ipath_snap_cntr(dd, dd->ipath_cregs->cr_wordsendcnt); 223 - ipath_snap_cntr(dd, dd->ipath_cregs->cr_wordrcvcnt); 224 227 ipath_snap_cntr(dd, dd->ipath_cregs->cr_pktsendcnt); 225 228 ipath_snap_cntr(dd, dd->ipath_cregs->cr_pktrcvcnt); 226 229 }
+42 -1
drivers/infiniband/hw/ipath/ipath_sysfs.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 596 596 return ret; 597 597 } 598 598 599 + static ssize_t store_led_override(struct device *dev, 600 + struct device_attribute *attr, 601 + const char *buf, 602 + size_t count) 603 + { 604 + struct ipath_devdata *dd = dev_get_drvdata(dev); 605 + int ret; 606 + u16 val; 607 + 608 + ret = ipath_parse_ushort(buf, &val); 609 + if (ret > 0) 610 + ipath_set_led_override(dd, val); 611 + else 612 + ipath_dev_err(dd, "attempt to set invalid LED override\n"); 613 + return ret; 614 + } 615 + 616 + static ssize_t show_logged_errs(struct device *dev, 617 + struct device_attribute *attr, 618 + char *buf) 619 + { 620 + struct ipath_devdata *dd = dev_get_drvdata(dev); 621 + int idx, count; 622 + 623 + /* force consistency with actual EEPROM */ 624 + if (ipath_update_eeprom_log(dd) != 0) 625 + return -ENXIO; 626 + 627 + count = 0; 628 + for (idx = 0; idx < IPATH_EEP_LOG_CNT; ++idx) { 629 + count += scnprintf(buf + count, PAGE_SIZE - count, "%d%c", 630 + dd->ipath_eep_st_errs[idx], 631 + idx == (IPATH_EEP_LOG_CNT - 1) ? '\n' : ' '); 632 + } 633 + 634 + return count; 635 + } 599 636 600 637 static DRIVER_ATTR(num_units, S_IRUGO, show_num_units, NULL); 601 638 static DRIVER_ATTR(version, S_IRUGO, show_version, NULL); ··· 662 625 static DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL); 663 626 static DEVICE_ATTR(unit, S_IRUGO, show_unit, NULL); 664 627 static DEVICE_ATTR(rx_pol_inv, S_IWUSR, NULL, store_rx_pol_inv); 628 + static DEVICE_ATTR(led_override, S_IWUSR, NULL, store_led_override); 629 + static DEVICE_ATTR(logged_errors, S_IRUGO, show_logged_errs, NULL); 665 630 666 631 static struct attribute *dev_attributes[] = { 667 632 &dev_attr_guid.attr, ··· 680 641 &dev_attr_unit.attr, 681 642 &dev_attr_enabled.attr, 682 643 &dev_attr_rx_pol_inv.attr, 644 + &dev_attr_led_override.attr, 645 + &dev_attr_logged_errors.attr, 683 646 NULL 684 647 }; 685 648
+5 -4
drivers/infiniband/hw/ipath/ipath_uc.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 58 58 wc->port_num = 0; 59 59 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 0); 60 60 } 61 - wqe = get_swqe_ptr(qp, qp->s_last); 62 61 } 63 62 64 63 /** ··· 86 87 87 88 /* header size in 32-bit words LRH+BTH = (8+12)/4. */ 88 89 hwords = 5; 89 - bth0 = 0; 90 + bth0 = 1 << 22; /* Set M bit */ 90 91 91 92 /* Get the next send request. */ 92 93 wqe = get_swqe_ptr(qp, qp->s_last); ··· 96 97 * Signal the completion of the last send 97 98 * (if there is one). 98 99 */ 99 - if (qp->s_last != qp->s_tail) 100 + if (qp->s_last != qp->s_tail) { 100 101 complete_last_send(qp, wqe, &wc); 102 + wqe = get_swqe_ptr(qp, qp->s_last); 103 + } 101 104 102 105 /* Check if send work queue is empty. */ 103 106 if (qp->s_tail == qp->s_head)
+5 -1
drivers/infiniband/hw/ipath/ipath_ud.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 176 176 dev->n_pkt_drops++; 177 177 goto bail_sge; 178 178 } 179 + /* Make sure entry is read after head index is read. */ 180 + smp_rmb(); 179 181 wqe = get_rwqe_ptr(rq, tail); 180 182 if (++tail >= rq->size) 181 183 tail = 0; ··· 233 231 234 232 if (len > length) 235 233 len = length; 234 + if (len > sge->sge_length) 235 + len = sge->sge_length; 236 236 BUG_ON(len == 0); 237 237 ipath_copy_sge(&rsge, sge->vaddr, len); 238 238 sge->vaddr += len;
+1 -1
drivers/infiniband/hw/ipath/ipath_user_pages.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+18 -11
drivers/infiniband/hw/ipath/ipath_verbs.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 164 164 while (length) { 165 165 u32 len = sge->length; 166 166 167 - BUG_ON(len == 0); 168 167 if (len > length) 169 168 len = length; 169 + if (len > sge->sge_length) 170 + len = sge->sge_length; 171 + BUG_ON(len == 0); 170 172 memcpy(sge->vaddr, data, len); 171 173 sge->vaddr += len; 172 174 sge->length -= len; ··· 204 202 while (length) { 205 203 u32 len = sge->length; 206 204 207 - BUG_ON(len == 0); 208 205 if (len > length) 209 206 len = length; 207 + if (len > sge->sge_length) 208 + len = sge->sge_length; 209 + BUG_ON(len == 0); 210 210 sge->vaddr += len; 211 211 sge->length -= len; 212 212 sge->sge_length -= len; ··· 327 323 wqe->num_sge = wr->num_sge; 328 324 for (i = 0; i < wr->num_sge; i++) 329 325 wqe->sg_list[i] = wr->sg_list[i]; 326 + /* Make sure queue entry is written before the head index. */ 327 + smp_wmb(); 330 328 wq->head = next; 331 329 spin_unlock_irqrestore(&qp->r_rq.lock, flags); 332 330 } ··· 954 948 qp = list_entry(dev->piowait.next, struct ipath_qp, 955 949 piowait); 956 950 list_del_init(&qp->piowait); 951 + clear_bit(IPATH_S_BUSY, &qp->s_busy); 957 952 tasklet_hi_schedule(&qp->s_task); 958 953 } 959 954 spin_unlock_irqrestore(&dev->pending_lock, flags); ··· 988 981 props->max_ah = ib_ipath_max_ahs; 989 982 props->max_cqe = ib_ipath_max_cqes; 990 983 props->max_mr = dev->lk_table.max; 984 + props->max_fmr = dev->lk_table.max; 985 + props->max_map_per_fmr = 32767; 991 986 props->max_pd = ib_ipath_max_pds; 992 987 props->max_qp_rd_atom = IPATH_MAX_RDMA_ATOMIC; 993 988 props->max_qp_init_rd_atom = 255; ··· 1060 1051 props->max_vl_num = 1; /* VLCap = VL0 */ 1061 1052 props->init_type_reply = 0; 1062 1053 1063 - props->max_mtu = IB_MTU_4096; 1054 + /* 1055 + * Note: the chips support a maximum MTU of 4096, but the driver 1056 + * hasn't implemented this feature yet, so set the maximum value 1057 + * to 2048. 1058 + */ 1059 + props->max_mtu = IB_MTU_2048; 1064 1060 switch (dev->dd->ipath_ibmtu) { 1065 1061 case 4096: 1066 1062 mtu = IB_MTU_4096; ··· 1374 1360 static void __verbs_timer(unsigned long arg) 1375 1361 { 1376 1362 struct ipath_devdata *dd = (struct ipath_devdata *) arg; 1377 - 1378 - /* 1379 - * If port 0 receive packet interrupts are not available, or 1380 - * can be missed, poll the receive queue 1381 - */ 1382 - if (dd->ipath_flags & IPATH_POLL_RX_INTR) 1383 - ipath_kreceive(dd); 1384 1363 1385 1364 /* Handle verbs layer timeouts. */ 1386 1365 ipath_ib_timer(dd->verbs_dev);
+2 -1
drivers/infiniband/hw/ipath/ipath_verbs.h
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 321 321 */ 322 322 struct ipath_ack_entry { 323 323 u8 opcode; 324 + u8 sent; 324 325 u32 psn; 325 326 union { 326 327 struct ipath_sge_state rdma_sge;
+1 -1
drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two
+1 -1
drivers/infiniband/hw/ipath/ipath_wc_ppc64.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * 4 4 * This software is available to you under a choice of one of two 5 5 * licenses. You may choose to be licensed under the terms of the GNU
+23 -6
drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
··· 1 1 /* 2 - * Copyright (c) 2006 QLogic, Inc. All rights reserved. 2 + * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 3 3 * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 4 4 * 5 5 * This software is available to you under a choice of one of two ··· 63 63 * of 2 address matching the length (which has to be a power of 2). 64 64 * For rev1, that means the base address, for rev2, it will be just 65 65 * the PIO buffers themselves. 66 + * For chips with two sets of buffers, the calculations are 67 + * somewhat more complicated; we need to sum, and the piobufbase 68 + * register has both offsets, 2K in low 32 bits, 4K in high 32 bits. 69 + * The buffers are still packed, so a single range covers both. 66 70 */ 67 - pioaddr = addr + dd->ipath_piobufbase; 68 - piolen = (dd->ipath_piobcnt2k + 69 - dd->ipath_piobcnt4k) * 70 - ALIGN(dd->ipath_piobcnt2k + 71 - dd->ipath_piobcnt4k, dd->ipath_palign); 71 + if (dd->ipath_piobcnt2k && dd->ipath_piobcnt4k) { /* 2 sizes */ 72 + unsigned long pio2kbase, pio4kbase; 73 + pio2kbase = dd->ipath_piobufbase & 0xffffffffUL; 74 + pio4kbase = (dd->ipath_piobufbase >> 32) & 0xffffffffUL; 75 + if (pio2kbase < pio4kbase) { /* all, for now */ 76 + pioaddr = addr + pio2kbase; 77 + piolen = pio4kbase - pio2kbase + 78 + dd->ipath_piobcnt4k * dd->ipath_4kalign; 79 + } else { 80 + pioaddr = addr + pio4kbase; 81 + piolen = pio2kbase - pio4kbase + 82 + dd->ipath_piobcnt2k * dd->ipath_palign; 83 + } 84 + } else { /* single buffer size (2K, currently) */ 85 + pioaddr = addr + dd->ipath_piobufbase; 86 + piolen = dd->ipath_piobcnt2k * dd->ipath_palign + 87 + dd->ipath_piobcnt4k * dd->ipath_4kalign; 88 + } 72 89 73 90 for (bits = 0; !(piolen & (1ULL << bits)); bits++) 74 91 /* do nothing */ ;
-1
drivers/infiniband/hw/mlx4/Kconfig
··· 1 1 config MLX4_INFINIBAND 2 2 tristate "Mellanox ConnectX HCA support" 3 - depends on INFINIBAND 4 3 select MLX4_CORE 5 4 ---help--- 6 5 This driver provides low-level InfiniBand support for
+5 -1
drivers/infiniband/hw/mlx4/main.c
··· 169 169 props->phys_state = out_mad->data[33] >> 4; 170 170 props->port_cap_flags = be32_to_cpup((__be32 *) (out_mad->data + 20)); 171 171 props->gid_tbl_len = to_mdev(ibdev)->dev->caps.gid_table_len[port]; 172 - props->max_msg_sz = 0x80000000; 172 + props->max_msg_sz = to_mdev(ibdev)->dev->caps.max_msg_sz; 173 173 props->pkey_tbl_len = to_mdev(ibdev)->dev->caps.pkey_table_len[port]; 174 174 props->bad_pkey_cntr = be16_to_cpup((__be16 *) (out_mad->data + 46)); 175 175 props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48)); ··· 523 523 (1ull << IB_USER_VERBS_CMD_DESTROY_CQ) | 524 524 (1ull << IB_USER_VERBS_CMD_CREATE_QP) | 525 525 (1ull << IB_USER_VERBS_CMD_MODIFY_QP) | 526 + (1ull << IB_USER_VERBS_CMD_QUERY_QP) | 526 527 (1ull << IB_USER_VERBS_CMD_DESTROY_QP) | 527 528 (1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) | 528 529 (1ull << IB_USER_VERBS_CMD_DETACH_MCAST) | 529 530 (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) | 530 531 (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) | 532 + (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) | 531 533 (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ); 532 534 533 535 ibdev->ib_dev.query_device = mlx4_ib_query_device; ··· 548 546 ibdev->ib_dev.destroy_ah = mlx4_ib_destroy_ah; 549 547 ibdev->ib_dev.create_srq = mlx4_ib_create_srq; 550 548 ibdev->ib_dev.modify_srq = mlx4_ib_modify_srq; 549 + ibdev->ib_dev.query_srq = mlx4_ib_query_srq; 551 550 ibdev->ib_dev.destroy_srq = mlx4_ib_destroy_srq; 552 551 ibdev->ib_dev.post_srq_recv = mlx4_ib_post_srq_recv; 553 552 ibdev->ib_dev.create_qp = mlx4_ib_create_qp; 554 553 ibdev->ib_dev.modify_qp = mlx4_ib_modify_qp; 554 + ibdev->ib_dev.query_qp = mlx4_ib_query_qp; 555 555 ibdev->ib_dev.destroy_qp = mlx4_ib_destroy_qp; 556 556 ibdev->ib_dev.post_send = mlx4_ib_post_send; 557 557 ibdev->ib_dev.post_recv = mlx4_ib_post_recv;
+4
drivers/infiniband/hw/mlx4/mlx4_ib.h
··· 35 35 36 36 #include <linux/compiler.h> 37 37 #include <linux/list.h> 38 + #include <linux/mutex.h> 38 39 39 40 #include <rdma/ib_verbs.h> 40 41 #include <rdma/ib_umem.h> ··· 256 255 struct ib_udata *udata); 257 256 int mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, 258 257 enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); 258 + int mlx4_ib_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr); 259 259 int mlx4_ib_destroy_srq(struct ib_srq *srq); 260 260 void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index); 261 261 int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, ··· 268 266 int mlx4_ib_destroy_qp(struct ib_qp *qp); 269 267 int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 270 268 int attr_mask, struct ib_udata *udata); 269 + int mlx4_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, 270 + struct ib_qp_init_attr *qp_init_attr); 271 271 int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, 272 272 struct ib_send_wr **bad_wr); 273 273 int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
+137
drivers/infiniband/hw/mlx4/qp.c
··· 1455 1455 1456 1456 return err; 1457 1457 } 1458 + 1459 + static inline enum ib_qp_state to_ib_qp_state(enum mlx4_qp_state mlx4_state) 1460 + { 1461 + switch (mlx4_state) { 1462 + case MLX4_QP_STATE_RST: return IB_QPS_RESET; 1463 + case MLX4_QP_STATE_INIT: return IB_QPS_INIT; 1464 + case MLX4_QP_STATE_RTR: return IB_QPS_RTR; 1465 + case MLX4_QP_STATE_RTS: return IB_QPS_RTS; 1466 + case MLX4_QP_STATE_SQ_DRAINING: 1467 + case MLX4_QP_STATE_SQD: return IB_QPS_SQD; 1468 + case MLX4_QP_STATE_SQER: return IB_QPS_SQE; 1469 + case MLX4_QP_STATE_ERR: return IB_QPS_ERR; 1470 + default: return -1; 1471 + } 1472 + } 1473 + 1474 + static inline enum ib_mig_state to_ib_mig_state(int mlx4_mig_state) 1475 + { 1476 + switch (mlx4_mig_state) { 1477 + case MLX4_QP_PM_ARMED: return IB_MIG_ARMED; 1478 + case MLX4_QP_PM_REARM: return IB_MIG_REARM; 1479 + case MLX4_QP_PM_MIGRATED: return IB_MIG_MIGRATED; 1480 + default: return -1; 1481 + } 1482 + } 1483 + 1484 + static int to_ib_qp_access_flags(int mlx4_flags) 1485 + { 1486 + int ib_flags = 0; 1487 + 1488 + if (mlx4_flags & MLX4_QP_BIT_RRE) 1489 + ib_flags |= IB_ACCESS_REMOTE_READ; 1490 + if (mlx4_flags & MLX4_QP_BIT_RWE) 1491 + ib_flags |= IB_ACCESS_REMOTE_WRITE; 1492 + if (mlx4_flags & MLX4_QP_BIT_RAE) 1493 + ib_flags |= IB_ACCESS_REMOTE_ATOMIC; 1494 + 1495 + return ib_flags; 1496 + } 1497 + 1498 + static void to_ib_ah_attr(struct mlx4_dev *dev, struct ib_ah_attr *ib_ah_attr, 1499 + struct mlx4_qp_path *path) 1500 + { 1501 + memset(ib_ah_attr, 0, sizeof *path); 1502 + ib_ah_attr->port_num = path->sched_queue & 0x40 ? 2 : 1; 1503 + 1504 + if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->caps.num_ports) 1505 + return; 1506 + 1507 + ib_ah_attr->dlid = be16_to_cpu(path->rlid); 1508 + ib_ah_attr->sl = (path->sched_queue >> 2) & 0xf; 1509 + ib_ah_attr->src_path_bits = path->grh_mylmc & 0x7f; 1510 + ib_ah_attr->static_rate = path->static_rate ? path->static_rate - 5 : 0; 1511 + ib_ah_attr->ah_flags = (path->grh_mylmc & (1 << 7)) ? IB_AH_GRH : 0; 1512 + if (ib_ah_attr->ah_flags) { 1513 + ib_ah_attr->grh.sgid_index = path->mgid_index; 1514 + ib_ah_attr->grh.hop_limit = path->hop_limit; 1515 + ib_ah_attr->grh.traffic_class = 1516 + (be32_to_cpu(path->tclass_flowlabel) >> 20) & 0xff; 1517 + ib_ah_attr->grh.flow_label = 1518 + be32_to_cpu(path->tclass_flowlabel) & 0xffffff; 1519 + memcpy(ib_ah_attr->grh.dgid.raw, 1520 + path->rgid, sizeof ib_ah_attr->grh.dgid.raw); 1521 + } 1522 + } 1523 + 1524 + int mlx4_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, 1525 + struct ib_qp_init_attr *qp_init_attr) 1526 + { 1527 + struct mlx4_ib_dev *dev = to_mdev(ibqp->device); 1528 + struct mlx4_ib_qp *qp = to_mqp(ibqp); 1529 + struct mlx4_qp_context context; 1530 + int mlx4_state; 1531 + int err; 1532 + 1533 + if (qp->state == IB_QPS_RESET) { 1534 + qp_attr->qp_state = IB_QPS_RESET; 1535 + goto done; 1536 + } 1537 + 1538 + err = mlx4_qp_query(dev->dev, &qp->mqp, &context); 1539 + if (err) 1540 + return -EINVAL; 1541 + 1542 + mlx4_state = be32_to_cpu(context.flags) >> 28; 1543 + 1544 + qp_attr->qp_state = to_ib_qp_state(mlx4_state); 1545 + qp_attr->path_mtu = context.mtu_msgmax >> 5; 1546 + qp_attr->path_mig_state = 1547 + to_ib_mig_state((be32_to_cpu(context.flags) >> 11) & 0x3); 1548 + qp_attr->qkey = be32_to_cpu(context.qkey); 1549 + qp_attr->rq_psn = be32_to_cpu(context.rnr_nextrecvpsn) & 0xffffff; 1550 + qp_attr->sq_psn = be32_to_cpu(context.next_send_psn) & 0xffffff; 1551 + qp_attr->dest_qp_num = be32_to_cpu(context.remote_qpn) & 0xffffff; 1552 + qp_attr->qp_access_flags = 1553 + to_ib_qp_access_flags(be32_to_cpu(context.params2)); 1554 + 1555 + if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) { 1556 + to_ib_ah_attr(dev->dev, &qp_attr->ah_attr, &context.pri_path); 1557 + to_ib_ah_attr(dev->dev, &qp_attr->alt_ah_attr, &context.alt_path); 1558 + qp_attr->alt_pkey_index = context.alt_path.pkey_index & 0x7f; 1559 + qp_attr->alt_port_num = qp_attr->alt_ah_attr.port_num; 1560 + } 1561 + 1562 + qp_attr->pkey_index = context.pri_path.pkey_index & 0x7f; 1563 + qp_attr->port_num = context.pri_path.sched_queue & 0x40 ? 2 : 1; 1564 + 1565 + /* qp_attr->en_sqd_async_notify is only applicable in modify qp */ 1566 + qp_attr->sq_draining = mlx4_state == MLX4_QP_STATE_SQ_DRAINING; 1567 + 1568 + qp_attr->max_rd_atomic = 1 << ((be32_to_cpu(context.params1) >> 21) & 0x7); 1569 + 1570 + qp_attr->max_dest_rd_atomic = 1571 + 1 << ((be32_to_cpu(context.params2) >> 21) & 0x7); 1572 + qp_attr->min_rnr_timer = 1573 + (be32_to_cpu(context.rnr_nextrecvpsn) >> 24) & 0x1f; 1574 + qp_attr->timeout = context.pri_path.ackto >> 3; 1575 + qp_attr->retry_cnt = (be32_to_cpu(context.params1) >> 16) & 0x7; 1576 + qp_attr->rnr_retry = (be32_to_cpu(context.params1) >> 13) & 0x7; 1577 + qp_attr->alt_timeout = context.alt_path.ackto >> 3; 1578 + 1579 + done: 1580 + qp_attr->cur_qp_state = qp_attr->qp_state; 1581 + if (!ibqp->uobject) { 1582 + qp_attr->cap.max_send_wr = qp->sq.wqe_cnt; 1583 + qp_attr->cap.max_recv_wr = qp->rq.wqe_cnt; 1584 + qp_attr->cap.max_send_sge = qp->sq.max_gs; 1585 + qp_attr->cap.max_recv_sge = qp->rq.max_gs; 1586 + qp_attr->cap.max_inline_data = (1 << qp->sq.wqe_shift) - 1587 + send_wqe_overhead(qp->ibqp.qp_type) - 1588 + sizeof (struct mlx4_wqe_inline_seg); 1589 + qp_init_attr->cap = qp_attr->cap; 1590 + } 1591 + 1592 + return 0; 1593 + } 1594 +
+18
drivers/infiniband/hw/mlx4/srq.c
··· 240 240 return 0; 241 241 } 242 242 243 + int mlx4_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr) 244 + { 245 + struct mlx4_ib_dev *dev = to_mdev(ibsrq->device); 246 + struct mlx4_ib_srq *srq = to_msrq(ibsrq); 247 + int ret; 248 + int limit_watermark; 249 + 250 + ret = mlx4_srq_query(dev->dev, &srq->msrq, &limit_watermark); 251 + if (ret) 252 + return ret; 253 + 254 + srq_attr->srq_limit = be16_to_cpu(limit_watermark); 255 + srq_attr->max_wr = srq->msrq.max - 1; 256 + srq_attr->max_sge = srq->msrq.max_gs; 257 + 258 + return 0; 259 + } 260 + 243 261 int mlx4_ib_destroy_srq(struct ib_srq *srq) 244 262 { 245 263 struct mlx4_ib_dev *dev = to_mdev(srq->device);
+1 -1
drivers/infiniband/hw/mthca/Kconfig
··· 1 1 config INFINIBAND_MTHCA 2 2 tristate "Mellanox HCA support" 3 - depends on PCI && INFINIBAND 3 + depends on PCI 4 4 ---help--- 5 5 This is a low-level driver for Mellanox InfiniHost host 6 6 channel adapters (HCAs), including the MT23108 PCI-X HCA
+1 -1
drivers/infiniband/hw/mthca/mthca_allocator.c
··· 255 255 dma_list[i] = t; 256 256 pci_unmap_addr_set(&buf->page_list[i], mapping, t); 257 257 258 - memset(buf->page_list[i].buf, 0, PAGE_SIZE); 258 + clear_page(buf->page_list[i].buf); 259 259 } 260 260 } 261 261
+1 -1
drivers/infiniband/hw/mthca/mthca_eq.c
··· 522 522 dma_list[i] = t; 523 523 pci_unmap_addr_set(&eq->page_list[i], mapping, t); 524 524 525 - memset(eq->page_list[i].buf, 0, PAGE_SIZE); 525 + clear_page(eq->page_list[i].buf); 526 526 } 527 527 528 528 for (i = 0; i < eq->nent; ++i)
+1 -1
drivers/infiniband/ulp/ipoib/Kconfig
··· 1 1 config INFINIBAND_IPOIB 2 2 tristate "IP-over-InfiniBand" 3 - depends on INFINIBAND && NETDEVICES && INET && (IPV6 || IPV6=n) 3 + depends on NETDEVICES && INET && (IPV6 || IPV6=n) 4 4 ---help--- 5 5 Support for the IP-over-InfiniBand protocol (IPoIB). This 6 6 transports IP packets over InfiniBand so you can use your IB
+1 -3
drivers/infiniband/ulp/ipoib/ipoib_cm.c
··· 281 281 rep.private_data_len = sizeof data; 282 282 rep.flow_control = 0; 283 283 rep.rnr_retry_count = req->rnr_retry_count; 284 - rep.target_ack_delay = 20; /* FIXME */ 285 284 rep.srq = 1; 286 285 rep.qp_num = qp->qp_num; 287 286 rep.starting_psn = psn; ··· 1147 1148 { 1148 1149 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, 1149 1150 cm.skb_task); 1150 - struct net_device *dev = priv->dev; 1151 1151 struct sk_buff *skb; 1152 1152 1153 1153 unsigned mtu = priv->mcast_mtu; ··· 1160 1162 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); 1161 1163 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1162 1164 else if (skb->protocol == htons(ETH_P_IPV6)) 1163 - icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, dev); 1165 + icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, priv->dev); 1164 1166 #endif 1165 1167 dev_kfree_skb_any(skb); 1166 1168 spin_lock_irq(&priv->tx_lock);
+17 -16
drivers/infiniband/ulp/ipoib/ipoib_ib.c
··· 197 197 } 198 198 199 199 /* 200 + * Drop packets that this interface sent, ie multicast packets 201 + * that the HCA has replicated. 202 + */ 203 + if (wc->slid == priv->local_lid && wc->src_qp == priv->qp->qp_num) 204 + goto repost; 205 + 206 + /* 200 207 * If we can't allocate a new RX buffer, dump 201 208 * this packet and reuse the old buffer. 202 209 */ ··· 220 213 skb_put(skb, wc->byte_len); 221 214 skb_pull(skb, IB_GRH_BYTES); 222 215 223 - if (wc->slid != priv->local_lid || 224 - wc->src_qp != priv->qp->qp_num) { 225 - skb->protocol = ((struct ipoib_header *) skb->data)->proto; 226 - skb_reset_mac_header(skb); 227 - skb_pull(skb, IPOIB_ENCAP_LEN); 216 + skb->protocol = ((struct ipoib_header *) skb->data)->proto; 217 + skb_reset_mac_header(skb); 218 + skb_pull(skb, IPOIB_ENCAP_LEN); 228 219 229 - dev->last_rx = jiffies; 230 - ++priv->stats.rx_packets; 231 - priv->stats.rx_bytes += skb->len; 220 + dev->last_rx = jiffies; 221 + ++priv->stats.rx_packets; 222 + priv->stats.rx_bytes += skb->len; 232 223 233 - skb->dev = dev; 234 - /* XXX get correct PACKET_ type here */ 235 - skb->pkt_type = PACKET_HOST; 236 - netif_receive_skb(skb); 237 - } else { 238 - ipoib_dbg_data(priv, "dropping loopback packet\n"); 239 - dev_kfree_skb_any(skb); 240 - } 224 + skb->dev = dev; 225 + /* XXX get correct PACKET_ type here */ 226 + skb->pkt_type = PACKET_HOST; 227 + netif_receive_skb(skb); 241 228 242 229 repost: 243 230 if (unlikely(ipoib_ib_post_receive(dev, wr_id)))
+1 -1
drivers/infiniband/ulp/iser/Kconfig
··· 1 1 config INFINIBAND_ISER 2 2 tristate "iSCSI Extensions for RDMA (iSER)" 3 - depends on INFINIBAND && SCSI && INET 3 + depends on SCSI && INET 4 4 select SCSI_ISCSI_ATTRS 5 5 ---help--- 6 6 Support for the iSCSI Extensions for RDMA (iSER) Protocol
+1 -1
drivers/infiniband/ulp/srp/Kconfig
··· 1 1 config INFINIBAND_SRP 2 2 tristate "InfiniBand SCSI RDMA Protocol" 3 - depends on INFINIBAND && SCSI 3 + depends on SCSI 4 4 ---help--- 5 5 Support for the SCSI RDMA Protocol over InfiniBand. This 6 6 allows you to access storage devices that speak SRP over
+1 -1
drivers/net/cxgb3/version.h
··· 39 39 40 40 /* Firmware version */ 41 41 #define FW_VERSION_MAJOR 4 42 - #define FW_VERSION_MINOR 1 42 + #define FW_VERSION_MINOR 3 43 43 #define FW_VERSION_MICRO 0 44 44 #endif /* __CHELSIO_VERSION_H */
+3
drivers/net/mlx4/fw.c
··· 138 138 #define QUERY_DEV_CAP_ACK_DELAY_OFFSET 0x35 139 139 #define QUERY_DEV_CAP_MTU_WIDTH_OFFSET 0x36 140 140 #define QUERY_DEV_CAP_VL_PORT_OFFSET 0x37 141 + #define QUERY_DEV_CAP_MAX_MSG_SZ_OFFSET 0x38 141 142 #define QUERY_DEV_CAP_MAX_GID_OFFSET 0x3b 142 143 #define QUERY_DEV_CAP_RATE_SUPPORT_OFFSET 0x3c 143 144 #define QUERY_DEV_CAP_MAX_PKEY_OFFSET 0x3f ··· 221 220 dev_cap->local_ca_ack_delay = field & 0x1f; 222 221 MLX4_GET(field, outbox, QUERY_DEV_CAP_VL_PORT_OFFSET); 223 222 dev_cap->num_ports = field & 0xf; 223 + MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MSG_SZ_OFFSET); 224 + dev_cap->max_msg_sz = 1 << (field & 0x1f); 224 225 MLX4_GET(stat_rate, outbox, QUERY_DEV_CAP_RATE_SUPPORT_OFFSET); 225 226 dev_cap->stat_rate_support = stat_rate; 226 227 MLX4_GET(dev_cap->flags, outbox, QUERY_DEV_CAP_FLAGS_OFFSET);
+1
drivers/net/mlx4/fw.h
··· 60 60 int max_rdma_global; 61 61 int local_ca_ack_delay; 62 62 int num_ports; 63 + u32 max_msg_sz; 63 64 int max_mtu[MLX4_MAX_PORTS + 1]; 64 65 int max_port_width[MLX4_MAX_PORTS + 1]; 65 66 int max_vl[MLX4_MAX_PORTS + 1];
+1
drivers/net/mlx4/main.c
··· 154 154 dev->caps.reserved_uars = dev_cap->reserved_uars; 155 155 dev->caps.reserved_pds = dev_cap->reserved_pds; 156 156 dev->caps.mtt_entry_sz = MLX4_MTT_ENTRY_PER_SEG * dev_cap->mtt_entry_sz; 157 + dev->caps.max_msg_sz = dev_cap->max_msg_sz; 157 158 dev->caps.page_size_cap = ~(u32) (dev_cap->min_page_sz - 1); 158 159 dev->caps.flags = dev_cap->flags; 159 160 dev->caps.stat_rate_support = dev_cap->stat_rate_support;
+1
drivers/net/mlx4/mlx4.h
··· 37 37 #ifndef MLX4_H 38 38 #define MLX4_H 39 39 40 + #include <linux/mutex.h> 40 41 #include <linux/radix-tree.h> 41 42 42 43 #include <linux/mlx4/device.h>
+21
drivers/net/mlx4/qp.c
··· 277 277 mlx4_CONF_SPECIAL_QP(dev, 0); 278 278 mlx4_bitmap_cleanup(&mlx4_priv(dev)->qp_table.bitmap); 279 279 } 280 + 281 + int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp, 282 + struct mlx4_qp_context *context) 283 + { 284 + struct mlx4_cmd_mailbox *mailbox; 285 + int err; 286 + 287 + mailbox = mlx4_alloc_cmd_mailbox(dev); 288 + if (IS_ERR(mailbox)) 289 + return PTR_ERR(mailbox); 290 + 291 + err = mlx4_cmd_box(dev, 0, mailbox->dma, qp->qpn, 0, 292 + MLX4_CMD_QUERY_QP, MLX4_CMD_TIME_CLASS_A); 293 + if (!err) 294 + memcpy(context, mailbox->buf + 8, sizeof *context); 295 + 296 + mlx4_free_cmd_mailbox(dev, mailbox); 297 + return err; 298 + } 299 + EXPORT_SYMBOL_GPL(mlx4_qp_query); 300 +
+30
drivers/net/mlx4/srq.c
··· 102 102 MLX4_CMD_TIME_CLASS_B); 103 103 } 104 104 105 + static int mlx4_QUERY_SRQ(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox, 106 + int srq_num) 107 + { 108 + return mlx4_cmd_box(dev, 0, mailbox->dma, srq_num, 0, MLX4_CMD_QUERY_SRQ, 109 + MLX4_CMD_TIME_CLASS_A); 110 + } 111 + 105 112 int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, struct mlx4_mtt *mtt, 106 113 u64 db_rec, struct mlx4_srq *srq) 107 114 { ··· 211 204 return mlx4_ARM_SRQ(dev, srq->srqn, limit_watermark); 212 205 } 213 206 EXPORT_SYMBOL_GPL(mlx4_srq_arm); 207 + 208 + int mlx4_srq_query(struct mlx4_dev *dev, struct mlx4_srq *srq, int *limit_watermark) 209 + { 210 + struct mlx4_cmd_mailbox *mailbox; 211 + struct mlx4_srq_context *srq_context; 212 + int err; 213 + 214 + mailbox = mlx4_alloc_cmd_mailbox(dev); 215 + if (IS_ERR(mailbox)) 216 + return PTR_ERR(mailbox); 217 + 218 + srq_context = mailbox->buf; 219 + 220 + err = mlx4_QUERY_SRQ(dev, mailbox, srq->srqn); 221 + if (err) 222 + goto err_out; 223 + *limit_watermark = srq_context->limit_watermark; 224 + 225 + err_out: 226 + mlx4_free_cmd_mailbox(dev, mailbox); 227 + return err; 228 + } 229 + EXPORT_SYMBOL_GPL(mlx4_srq_query); 214 230 215 231 int __devinit mlx4_init_srq_table(struct mlx4_dev *dev) 216 232 {
+2
include/linux/mlx4/device.h
··· 172 172 int num_pds; 173 173 int reserved_pds; 174 174 int mtt_entry_sz; 175 + u32 max_msg_sz; 175 176 u32 page_size_cap; 176 177 u32 flags; 177 178 u16 stat_rate_support; ··· 323 322 u64 db_rec, struct mlx4_srq *srq); 324 323 void mlx4_srq_free(struct mlx4_dev *dev, struct mlx4_srq *srq); 325 324 int mlx4_srq_arm(struct mlx4_dev *dev, struct mlx4_srq *srq, int limit_watermark); 325 + int mlx4_srq_query(struct mlx4_dev *dev, struct mlx4_srq *srq, int *limit_watermark); 326 326 327 327 int mlx4_INIT_PORT(struct mlx4_dev *dev, int port); 328 328 int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
+3
include/linux/mlx4/qp.h
··· 282 282 struct mlx4_qp_context *context, enum mlx4_qp_optpar optpar, 283 283 int sqd_event, struct mlx4_qp *qp); 284 284 285 + int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp, 286 + struct mlx4_qp_context *context); 287 + 285 288 static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn) 286 289 { 287 290 return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1));
-1
include/rdma/ib_cm.h
··· 385 385 u8 private_data_len; 386 386 u8 responder_resources; 387 387 u8 initiator_depth; 388 - u8 target_ack_delay; 389 388 u8 failover_accepted; 390 389 u8 flow_control; 391 390 u8 rnr_retry_count;
+3
include/rdma/ib_mad.h
··· 111 111 #define IB_QP1_QKEY 0x80010000 112 112 #define IB_QP_SET_QKEY 0x80000000 113 113 114 + #define IB_DEFAULT_PKEY_PARTIAL 0x7FFF 115 + #define IB_DEFAULT_PKEY_FULL 0xFFFF 116 + 114 117 enum { 115 118 IB_MGMT_MAD_HDR = 24, 116 119 IB_MGMT_MAD_DATA = 232,