diff options
Diffstat (limited to 'drivers/infiniband/ulp/ipoib/ipoib_ib.c')
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_ib.c | 118 |
1 files changed, 88 insertions, 30 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 68d72c6f7ffb..8404f05b2b6e 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -448,6 +448,13 @@ int ipoib_ib_dev_open(struct net_device *dev) | |||
448 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 448 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
449 | int ret; | 449 | int ret; |
450 | 450 | ||
451 | if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &priv->pkey_index)) { | ||
452 | ipoib_warn(priv, "P_Key 0x%04x not found\n", priv->pkey); | ||
453 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); | ||
454 | return -1; | ||
455 | } | ||
456 | set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); | ||
457 | |||
451 | ret = ipoib_init_qp(dev); | 458 | ret = ipoib_init_qp(dev); |
452 | if (ret) { | 459 | if (ret) { |
453 | ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret); | 460 | ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret); |
@@ -457,14 +464,14 @@ int ipoib_ib_dev_open(struct net_device *dev) | |||
457 | ret = ipoib_ib_post_receives(dev); | 464 | ret = ipoib_ib_post_receives(dev); |
458 | if (ret) { | 465 | if (ret) { |
459 | ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret); | 466 | ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret); |
460 | ipoib_ib_dev_stop(dev); | 467 | ipoib_ib_dev_stop(dev, 1); |
461 | return -1; | 468 | return -1; |
462 | } | 469 | } |
463 | 470 | ||
464 | ret = ipoib_cm_dev_open(dev); | 471 | ret = ipoib_cm_dev_open(dev); |
465 | if (ret) { | 472 | if (ret) { |
466 | ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret); | 473 | ipoib_warn(priv, "ipoib_cm_dev_open returned %d\n", ret); |
467 | ipoib_ib_dev_stop(dev); | 474 | ipoib_ib_dev_stop(dev, 1); |
468 | return -1; | 475 | return -1; |
469 | } | 476 | } |
470 | 477 | ||
@@ -516,7 +523,7 @@ int ipoib_ib_dev_down(struct net_device *dev, int flush) | |||
516 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { | 523 | if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) { |
517 | mutex_lock(&pkey_mutex); | 524 | mutex_lock(&pkey_mutex); |
518 | set_bit(IPOIB_PKEY_STOP, &priv->flags); | 525 | set_bit(IPOIB_PKEY_STOP, &priv->flags); |
519 | cancel_delayed_work(&priv->pkey_task); | 526 | cancel_delayed_work(&priv->pkey_poll_task); |
520 | mutex_unlock(&pkey_mutex); | 527 | mutex_unlock(&pkey_mutex); |
521 | if (flush) | 528 | if (flush) |
522 | flush_workqueue(ipoib_workqueue); | 529 | flush_workqueue(ipoib_workqueue); |
@@ -543,13 +550,30 @@ static int recvs_pending(struct net_device *dev) | |||
543 | return pending; | 550 | return pending; |
544 | } | 551 | } |
545 | 552 | ||
546 | int ipoib_ib_dev_stop(struct net_device *dev) | 553 | void ipoib_drain_cq(struct net_device *dev) |
554 | { | ||
555 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
556 | int i, n; | ||
557 | do { | ||
558 | n = ib_poll_cq(priv->cq, IPOIB_NUM_WC, priv->ibwc); | ||
559 | for (i = 0; i < n; ++i) { | ||
560 | if (priv->ibwc[i].wr_id & IPOIB_CM_OP_SRQ) | ||
561 | ipoib_cm_handle_rx_wc(dev, priv->ibwc + i); | ||
562 | else if (priv->ibwc[i].wr_id & IPOIB_OP_RECV) | ||
563 | ipoib_ib_handle_rx_wc(dev, priv->ibwc + i); | ||
564 | else | ||
565 | ipoib_ib_handle_tx_wc(dev, priv->ibwc + i); | ||
566 | } | ||
567 | } while (n == IPOIB_NUM_WC); | ||
568 | } | ||
569 | |||
570 | int ipoib_ib_dev_stop(struct net_device *dev, int flush) | ||
547 | { | 571 | { |
548 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 572 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
549 | struct ib_qp_attr qp_attr; | 573 | struct ib_qp_attr qp_attr; |
550 | unsigned long begin; | 574 | unsigned long begin; |
551 | struct ipoib_tx_buf *tx_req; | 575 | struct ipoib_tx_buf *tx_req; |
552 | int i, n; | 576 | int i; |
553 | 577 | ||
554 | clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); | 578 | clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); |
555 | netif_poll_disable(dev); | 579 | netif_poll_disable(dev); |
@@ -604,17 +628,7 @@ int ipoib_ib_dev_stop(struct net_device *dev) | |||
604 | goto timeout; | 628 | goto timeout; |
605 | } | 629 | } |
606 | 630 | ||
607 | do { | 631 | ipoib_drain_cq(dev); |
608 | n = ib_poll_cq(priv->cq, IPOIB_NUM_WC, priv->ibwc); | ||
609 | for (i = 0; i < n; ++i) { | ||
610 | if (priv->ibwc[i].wr_id & IPOIB_CM_OP_SRQ) | ||
611 | ipoib_cm_handle_rx_wc(dev, priv->ibwc + i); | ||
612 | else if (priv->ibwc[i].wr_id & IPOIB_OP_RECV) | ||
613 | ipoib_ib_handle_rx_wc(dev, priv->ibwc + i); | ||
614 | else | ||
615 | ipoib_ib_handle_tx_wc(dev, priv->ibwc + i); | ||
616 | } | ||
617 | } while (n == IPOIB_NUM_WC); | ||
618 | 632 | ||
619 | msleep(1); | 633 | msleep(1); |
620 | } | 634 | } |
@@ -629,7 +643,8 @@ timeout: | |||
629 | /* Wait for all AHs to be reaped */ | 643 | /* Wait for all AHs to be reaped */ |
630 | set_bit(IPOIB_STOP_REAPER, &priv->flags); | 644 | set_bit(IPOIB_STOP_REAPER, &priv->flags); |
631 | cancel_delayed_work(&priv->ah_reap_task); | 645 | cancel_delayed_work(&priv->ah_reap_task); |
632 | flush_workqueue(ipoib_workqueue); | 646 | if (flush) |
647 | flush_workqueue(ipoib_workqueue); | ||
633 | 648 | ||
634 | begin = jiffies; | 649 | begin = jiffies; |
635 | 650 | ||
@@ -673,13 +688,24 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port) | |||
673 | return 0; | 688 | return 0; |
674 | } | 689 | } |
675 | 690 | ||
676 | void ipoib_ib_dev_flush(struct work_struct *work) | 691 | static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event) |
677 | { | 692 | { |
678 | struct ipoib_dev_priv *cpriv, *priv = | 693 | struct ipoib_dev_priv *cpriv; |
679 | container_of(work, struct ipoib_dev_priv, flush_task); | ||
680 | struct net_device *dev = priv->dev; | 694 | struct net_device *dev = priv->dev; |
695 | u16 new_index; | ||
696 | |||
697 | mutex_lock(&priv->vlan_mutex); | ||
698 | |||
699 | /* | ||
700 | * Flush any child interfaces too -- they might be up even if | ||
701 | * the parent is down. | ||
702 | */ | ||
703 | list_for_each_entry(cpriv, &priv->child_intfs, list) | ||
704 | __ipoib_ib_dev_flush(cpriv, pkey_event); | ||
681 | 705 | ||
682 | if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) { | 706 | mutex_unlock(&priv->vlan_mutex); |
707 | |||
708 | if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) { | ||
683 | ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); | 709 | ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); |
684 | return; | 710 | return; |
685 | } | 711 | } |
@@ -689,10 +715,32 @@ void ipoib_ib_dev_flush(struct work_struct *work) | |||
689 | return; | 715 | return; |
690 | } | 716 | } |
691 | 717 | ||
718 | if (pkey_event) { | ||
719 | if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { | ||
720 | clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); | ||
721 | ipoib_ib_dev_down(dev, 0); | ||
722 | ipoib_pkey_dev_delay_open(dev); | ||
723 | return; | ||
724 | } | ||
725 | set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); | ||
726 | |||
727 | /* restart QP only if P_Key index is changed */ | ||
728 | if (new_index == priv->pkey_index) { | ||
729 | ipoib_dbg(priv, "Not flushing - P_Key index not changed.\n"); | ||
730 | return; | ||
731 | } | ||
732 | priv->pkey_index = new_index; | ||
733 | } | ||
734 | |||
692 | ipoib_dbg(priv, "flushing\n"); | 735 | ipoib_dbg(priv, "flushing\n"); |
693 | 736 | ||
694 | ipoib_ib_dev_down(dev, 0); | 737 | ipoib_ib_dev_down(dev, 0); |
695 | 738 | ||
739 | if (pkey_event) { | ||
740 | ipoib_ib_dev_stop(dev, 0); | ||
741 | ipoib_ib_dev_open(dev); | ||
742 | } | ||
743 | |||
696 | /* | 744 | /* |
697 | * The device could have been brought down between the start and when | 745 | * The device could have been brought down between the start and when |
698 | * we get here, don't bring it back up if it's not configured up | 746 | * we get here, don't bring it back up if it's not configured up |
@@ -701,14 +749,24 @@ void ipoib_ib_dev_flush(struct work_struct *work) | |||
701 | ipoib_ib_dev_up(dev); | 749 | ipoib_ib_dev_up(dev); |
702 | ipoib_mcast_restart_task(&priv->restart_task); | 750 | ipoib_mcast_restart_task(&priv->restart_task); |
703 | } | 751 | } |
752 | } | ||
704 | 753 | ||
705 | mutex_lock(&priv->vlan_mutex); | 754 | void ipoib_ib_dev_flush(struct work_struct *work) |
755 | { | ||
756 | struct ipoib_dev_priv *priv = | ||
757 | container_of(work, struct ipoib_dev_priv, flush_task); | ||
706 | 758 | ||
707 | /* Flush any child interfaces too */ | 759 | ipoib_dbg(priv, "Flushing %s\n", priv->dev->name); |
708 | list_for_each_entry(cpriv, &priv->child_intfs, list) | 760 | __ipoib_ib_dev_flush(priv, 0); |
709 | ipoib_ib_dev_flush(&cpriv->flush_task); | 761 | } |
710 | 762 | ||
711 | mutex_unlock(&priv->vlan_mutex); | 763 | void ipoib_pkey_event(struct work_struct *work) |
764 | { | ||
765 | struct ipoib_dev_priv *priv = | ||
766 | container_of(work, struct ipoib_dev_priv, pkey_event_task); | ||
767 | |||
768 | ipoib_dbg(priv, "Flushing %s and restarting its QP\n", priv->dev->name); | ||
769 | __ipoib_ib_dev_flush(priv, 1); | ||
712 | } | 770 | } |
713 | 771 | ||
714 | void ipoib_ib_dev_cleanup(struct net_device *dev) | 772 | void ipoib_ib_dev_cleanup(struct net_device *dev) |
@@ -736,7 +794,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev) | |||
736 | void ipoib_pkey_poll(struct work_struct *work) | 794 | void ipoib_pkey_poll(struct work_struct *work) |
737 | { | 795 | { |
738 | struct ipoib_dev_priv *priv = | 796 | struct ipoib_dev_priv *priv = |
739 | container_of(work, struct ipoib_dev_priv, pkey_task.work); | 797 | container_of(work, struct ipoib_dev_priv, pkey_poll_task.work); |
740 | struct net_device *dev = priv->dev; | 798 | struct net_device *dev = priv->dev; |
741 | 799 | ||
742 | ipoib_pkey_dev_check_presence(dev); | 800 | ipoib_pkey_dev_check_presence(dev); |
@@ -747,7 +805,7 @@ void ipoib_pkey_poll(struct work_struct *work) | |||
747 | mutex_lock(&pkey_mutex); | 805 | mutex_lock(&pkey_mutex); |
748 | if (!test_bit(IPOIB_PKEY_STOP, &priv->flags)) | 806 | if (!test_bit(IPOIB_PKEY_STOP, &priv->flags)) |
749 | queue_delayed_work(ipoib_workqueue, | 807 | queue_delayed_work(ipoib_workqueue, |
750 | &priv->pkey_task, | 808 | &priv->pkey_poll_task, |
751 | HZ); | 809 | HZ); |
752 | mutex_unlock(&pkey_mutex); | 810 | mutex_unlock(&pkey_mutex); |
753 | } | 811 | } |
@@ -766,7 +824,7 @@ int ipoib_pkey_dev_delay_open(struct net_device *dev) | |||
766 | mutex_lock(&pkey_mutex); | 824 | mutex_lock(&pkey_mutex); |
767 | clear_bit(IPOIB_PKEY_STOP, &priv->flags); | 825 | clear_bit(IPOIB_PKEY_STOP, &priv->flags); |
768 | queue_delayed_work(ipoib_workqueue, | 826 | queue_delayed_work(ipoib_workqueue, |
769 | &priv->pkey_task, | 827 | &priv->pkey_poll_task, |
770 | HZ); | 828 | HZ); |
771 | mutex_unlock(&pkey_mutex); | 829 | mutex_unlock(&pkey_mutex); |
772 | return 1; | 830 | return 1; |