diff options
Diffstat (limited to 'include/scsi/libfc.h')
-rw-r--r-- | include/scsi/libfc.h | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index a70eafaad084..0303a6a098cc 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/timer.h> | 23 | #include <linux/timer.h> |
24 | #include <linux/if.h> | 24 | #include <linux/if.h> |
25 | #include <linux/percpu.h> | ||
25 | 26 | ||
26 | #include <scsi/scsi_transport.h> | 27 | #include <scsi/scsi_transport.h> |
27 | #include <scsi/scsi_transport_fc.h> | 28 | #include <scsi/scsi_transport_fc.h> |
@@ -661,7 +662,8 @@ struct fc_lport { | |||
661 | unsigned long boot_time; | 662 | unsigned long boot_time; |
662 | 663 | ||
663 | struct fc_host_statistics host_stats; | 664 | struct fc_host_statistics host_stats; |
664 | struct fcoe_dev_stats *dev_stats[NR_CPUS]; | 665 | struct fcoe_dev_stats *dev_stats; |
666 | |||
665 | u64 wwpn; | 667 | u64 wwpn; |
666 | u64 wwnn; | 668 | u64 wwnn; |
667 | u8 retry_count; | 669 | u8 retry_count; |
@@ -694,11 +696,6 @@ struct fc_lport { | |||
694 | /* | 696 | /* |
695 | * FC_LPORT HELPER FUNCTIONS | 697 | * FC_LPORT HELPER FUNCTIONS |
696 | *****************************/ | 698 | *****************************/ |
697 | static inline void *lport_priv(const struct fc_lport *lp) | ||
698 | { | ||
699 | return (void *)(lp + 1); | ||
700 | } | ||
701 | |||
702 | static inline int fc_lport_test_ready(struct fc_lport *lp) | 699 | static inline int fc_lport_test_ready(struct fc_lport *lp) |
703 | { | 700 | { |
704 | return lp->state == LPORT_ST_READY; | 701 | return lp->state == LPORT_ST_READY; |
@@ -722,6 +719,42 @@ static inline void fc_lport_state_enter(struct fc_lport *lp, | |||
722 | lp->state = state; | 719 | lp->state = state; |
723 | } | 720 | } |
724 | 721 | ||
722 | static inline int fc_lport_init_stats(struct fc_lport *lp) | ||
723 | { | ||
724 | /* allocate per cpu stats block */ | ||
725 | lp->dev_stats = alloc_percpu(struct fcoe_dev_stats); | ||
726 | if (!lp->dev_stats) | ||
727 | return -ENOMEM; | ||
728 | return 0; | ||
729 | } | ||
730 | |||
731 | static inline void fc_lport_free_stats(struct fc_lport *lp) | ||
732 | { | ||
733 | free_percpu(lp->dev_stats); | ||
734 | } | ||
735 | |||
736 | static inline struct fcoe_dev_stats *fc_lport_get_stats(struct fc_lport *lp) | ||
737 | { | ||
738 | return per_cpu_ptr(lp->dev_stats, smp_processor_id()); | ||
739 | } | ||
740 | |||
741 | static inline void *lport_priv(const struct fc_lport *lp) | ||
742 | { | ||
743 | return (void *)(lp + 1); | ||
744 | } | ||
745 | |||
746 | /** | ||
747 | * libfc_host_alloc() - Allocate a Scsi_Host with room for the fc_lport | ||
748 | * @sht: ptr to the scsi host templ | ||
749 | * @priv_size: size of private data after fc_lport | ||
750 | * | ||
751 | * Returns: ptr to Scsi_Host | ||
752 | */ | ||
753 | static inline struct Scsi_Host * | ||
754 | libfc_host_alloc(struct scsi_host_template *sht, int priv_size) | ||
755 | { | ||
756 | return scsi_host_alloc(sht, sizeof(struct fc_lport) + priv_size); | ||
757 | } | ||
725 | 758 | ||
726 | /* | 759 | /* |
727 | * LOCAL PORT LAYER | 760 | * LOCAL PORT LAYER |