diff options
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_fcoe.c')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_fcoe.c | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/drivers/net/ixgbe/ixgbe_fcoe.c b/drivers/net/ixgbe/ixgbe_fcoe.c index 28cf104e36cc..0607cffbb213 100644 --- a/drivers/net/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ixgbe/ixgbe_fcoe.c | |||
@@ -27,6 +27,9 @@ | |||
27 | 27 | ||
28 | 28 | ||
29 | #include "ixgbe.h" | 29 | #include "ixgbe.h" |
30 | #ifdef CONFIG_IXGBE_DCB | ||
31 | #include "ixgbe_dcb_82599.h" | ||
32 | #endif /* CONFIG_IXGBE_DCB */ | ||
30 | #include <linux/if_ether.h> | 33 | #include <linux/if_ether.h> |
31 | #include <scsi/scsi_cmnd.h> | 34 | #include <scsi/scsi_cmnd.h> |
32 | #include <scsi/scsi_device.h> | 35 | #include <scsi/scsi_device.h> |
@@ -554,3 +557,158 @@ void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter) | |||
554 | fcoe->pool = NULL; | 557 | fcoe->pool = NULL; |
555 | } | 558 | } |
556 | } | 559 | } |
560 | |||
561 | /** | ||
562 | * ixgbe_fcoe_enable - turn on FCoE offload feature | ||
563 | * @netdev: the corresponding netdev | ||
564 | * | ||
565 | * Turns on FCoE offload feature in 82599. | ||
566 | * | ||
567 | * Returns : 0 indicates success or -EINVAL on failure | ||
568 | */ | ||
569 | int ixgbe_fcoe_enable(struct net_device *netdev) | ||
570 | { | ||
571 | int rc = -EINVAL; | ||
572 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | ||
573 | |||
574 | |||
575 | if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE)) | ||
576 | goto out_enable; | ||
577 | |||
578 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) | ||
579 | goto out_enable; | ||
580 | |||
581 | DPRINTK(DRV, INFO, "Enabling FCoE offload features.\n"); | ||
582 | if (netif_running(netdev)) | ||
583 | netdev->netdev_ops->ndo_stop(netdev); | ||
584 | |||
585 | ixgbe_clear_interrupt_scheme(adapter); | ||
586 | |||
587 | adapter->flags |= IXGBE_FLAG_FCOE_ENABLED; | ||
588 | adapter->ring_feature[RING_F_FCOE].indices = IXGBE_FCRETA_SIZE; | ||
589 | netdev->features |= NETIF_F_FCOE_CRC; | ||
590 | netdev->features |= NETIF_F_FSO; | ||
591 | netdev->features |= NETIF_F_FCOE_MTU; | ||
592 | netdev->vlan_features |= NETIF_F_FCOE_CRC; | ||
593 | netdev->vlan_features |= NETIF_F_FSO; | ||
594 | netdev->vlan_features |= NETIF_F_FCOE_MTU; | ||
595 | netdev->fcoe_ddp_xid = IXGBE_FCOE_DDP_MAX - 1; | ||
596 | netdev_features_change(netdev); | ||
597 | |||
598 | ixgbe_init_interrupt_scheme(adapter); | ||
599 | |||
600 | if (netif_running(netdev)) | ||
601 | netdev->netdev_ops->ndo_open(netdev); | ||
602 | rc = 0; | ||
603 | |||
604 | out_enable: | ||
605 | return rc; | ||
606 | } | ||
607 | |||
608 | /** | ||
609 | * ixgbe_fcoe_disable - turn off FCoE offload feature | ||
610 | * @netdev: the corresponding netdev | ||
611 | * | ||
612 | * Turns off FCoE offload feature in 82599. | ||
613 | * | ||
614 | * Returns : 0 indicates success or -EINVAL on failure | ||
615 | */ | ||
616 | int ixgbe_fcoe_disable(struct net_device *netdev) | ||
617 | { | ||
618 | int rc = -EINVAL; | ||
619 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | ||
620 | |||
621 | if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE)) | ||
622 | goto out_disable; | ||
623 | |||
624 | if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) | ||
625 | goto out_disable; | ||
626 | |||
627 | DPRINTK(DRV, INFO, "Disabling FCoE offload features.\n"); | ||
628 | if (netif_running(netdev)) | ||
629 | netdev->netdev_ops->ndo_stop(netdev); | ||
630 | |||
631 | ixgbe_clear_interrupt_scheme(adapter); | ||
632 | |||
633 | adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; | ||
634 | adapter->ring_feature[RING_F_FCOE].indices = 0; | ||
635 | netdev->features &= ~NETIF_F_FCOE_CRC; | ||
636 | netdev->features &= ~NETIF_F_FSO; | ||
637 | netdev->features &= ~NETIF_F_FCOE_MTU; | ||
638 | netdev->vlan_features &= ~NETIF_F_FCOE_CRC; | ||
639 | netdev->vlan_features &= ~NETIF_F_FSO; | ||
640 | netdev->vlan_features &= ~NETIF_F_FCOE_MTU; | ||
641 | netdev->fcoe_ddp_xid = 0; | ||
642 | netdev_features_change(netdev); | ||
643 | |||
644 | ixgbe_cleanup_fcoe(adapter); | ||
645 | |||
646 | ixgbe_init_interrupt_scheme(adapter); | ||
647 | if (netif_running(netdev)) | ||
648 | netdev->netdev_ops->ndo_open(netdev); | ||
649 | rc = 0; | ||
650 | |||
651 | out_disable: | ||
652 | return rc; | ||
653 | } | ||
654 | |||
655 | #ifdef CONFIG_IXGBE_DCB | ||
656 | /** | ||
657 | * ixgbe_fcoe_getapp - retrieves current user priority bitmap for FCoE | ||
658 | * @adapter : ixgbe adapter | ||
659 | * | ||
660 | * Finds out the corresponding user priority bitmap from the current | ||
661 | * traffic class that FCoE belongs to. Returns 0 as the invalid user | ||
662 | * priority bitmap to indicate an error. | ||
663 | * | ||
664 | * Returns : 802.1p user priority bitmap for FCoE | ||
665 | */ | ||
666 | u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter) | ||
667 | { | ||
668 | int i; | ||
669 | u8 tc; | ||
670 | u32 up2tc; | ||
671 | |||
672 | up2tc = IXGBE_READ_REG(&adapter->hw, IXGBE_RTTUP2TC); | ||
673 | for (i = 0; i < MAX_USER_PRIORITY; i++) { | ||
674 | tc = (u8)(up2tc >> (i * IXGBE_RTTUP2TC_UP_SHIFT)); | ||
675 | tc &= (MAX_TRAFFIC_CLASS - 1); | ||
676 | if (adapter->fcoe.tc == tc) | ||
677 | return 1 << i; | ||
678 | } | ||
679 | |||
680 | return 0; | ||
681 | } | ||
682 | |||
683 | /** | ||
684 | * ixgbe_fcoe_setapp - sets the user priority bitmap for FCoE | ||
685 | * @adapter : ixgbe adapter | ||
686 | * @up : 802.1p user priority bitmap | ||
687 | * | ||
688 | * Finds out the traffic class from the input user priority | ||
689 | * bitmap for FCoE. | ||
690 | * | ||
691 | * Returns : 0 on success otherwise returns 1 on error | ||
692 | */ | ||
693 | u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up) | ||
694 | { | ||
695 | int i; | ||
696 | u32 up2tc; | ||
697 | |||
698 | /* valid user priority bitmap must not be 0 */ | ||
699 | if (up) { | ||
700 | /* from user priority to the corresponding traffic class */ | ||
701 | up2tc = IXGBE_READ_REG(&adapter->hw, IXGBE_RTTUP2TC); | ||
702 | for (i = 0; i < MAX_USER_PRIORITY; i++) { | ||
703 | if (up & (1 << i)) { | ||
704 | up2tc >>= (i * IXGBE_RTTUP2TC_UP_SHIFT); | ||
705 | up2tc &= (MAX_TRAFFIC_CLASS - 1); | ||
706 | adapter->fcoe.tc = (u8)up2tc; | ||
707 | return 0; | ||
708 | } | ||
709 | } | ||
710 | } | ||
711 | |||
712 | return 1; | ||
713 | } | ||
714 | #endif /* CONFIG_IXGBE_DCB */ | ||