aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Eykholt <jeykholt@cisco.com>2010-07-20 18:19:53 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-07-28 10:05:52 -0400
commit0685230c59b5482e04ab50e7afc51119ceaba651 (patch)
tree64fbf16efb314efc5cba7e313342f0d57ce81e95
parentfdb068c6cd6e30d43664f856d3530715a5742713 (diff)
[SCSI] libfc: add discovery-private pointer for LLD
For VN_port to VN_port mode, FIP will do discovery and needs a way to find its state from the local port or discovery structure. It seems that any other LLD that implements its own discovery would also need something like this. Replace disc->lport with disc->priv, and use container_of to find the lport. We could use disc->priv for that, but container_of is smaller and faster. Signed-off-by: Joe Eykholt <jeykholt@cisco.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r--drivers/scsi/libfc/fc_disc.c14
-rw-r--r--drivers/scsi/libfc/fc_libfc.h2
-rw-r--r--include/scsi/libfc.h9
3 files changed, 15 insertions, 10 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index d0fa9a0ddc8d..04474556f2dc 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -65,7 +65,7 @@ void fc_disc_stop_rports(struct fc_disc *disc)
65 struct fc_lport *lport; 65 struct fc_lport *lport;
66 struct fc_rport_priv *rdata; 66 struct fc_rport_priv *rdata;
67 67
68 lport = disc->lport; 68 lport = fc_disc_lport(disc);
69 69
70 mutex_lock(&disc->disc_mutex); 70 mutex_lock(&disc->disc_mutex);
71 list_for_each_entry_rcu(rdata, &disc->rports, peers) 71 list_for_each_entry_rcu(rdata, &disc->rports, peers)
@@ -96,7 +96,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
96 LIST_HEAD(disc_ports); 96 LIST_HEAD(disc_ports);
97 struct fc_disc_port *dp, *next; 97 struct fc_disc_port *dp, *next;
98 98
99 lport = disc->lport; 99 lport = fc_disc_lport(disc);
100 100
101 FC_DISC_DBG(disc, "Received an RSCN event\n"); 101 FC_DISC_DBG(disc, "Received an RSCN event\n");
102 102
@@ -275,7 +275,7 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
275 */ 275 */
276static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event) 276static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
277{ 277{
278 struct fc_lport *lport = disc->lport; 278 struct fc_lport *lport = fc_disc_lport(disc);
279 struct fc_rport_priv *rdata; 279 struct fc_rport_priv *rdata;
280 280
281 FC_DISC_DBG(disc, "Discovery complete\n"); 281 FC_DISC_DBG(disc, "Discovery complete\n");
@@ -313,7 +313,7 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
313 */ 313 */
314static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) 314static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
315{ 315{
316 struct fc_lport *lport = disc->lport; 316 struct fc_lport *lport = fc_disc_lport(disc);
317 unsigned long delay = 0; 317 unsigned long delay = 0;
318 318
319 FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n", 319 FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
@@ -353,7 +353,7 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
353static void fc_disc_gpn_ft_req(struct fc_disc *disc) 353static void fc_disc_gpn_ft_req(struct fc_disc *disc)
354{ 354{
355 struct fc_frame *fp; 355 struct fc_frame *fp;
356 struct fc_lport *lport = disc->lport; 356 struct fc_lport *lport = fc_disc_lport(disc);
357 357
358 WARN_ON(!fc_lport_test_ready(lport)); 358 WARN_ON(!fc_lport_test_ready(lport));
359 359
@@ -396,7 +396,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
396 struct fc_rport_identifiers ids; 396 struct fc_rport_identifiers ids;
397 struct fc_rport_priv *rdata; 397 struct fc_rport_priv *rdata;
398 398
399 lport = disc->lport; 399 lport = fc_disc_lport(disc);
400 disc->seq_count++; 400 disc->seq_count++;
401 401
402 /* 402 /*
@@ -733,7 +733,7 @@ int fc_disc_init(struct fc_lport *lport)
733 mutex_init(&disc->disc_mutex); 733 mutex_init(&disc->disc_mutex);
734 INIT_LIST_HEAD(&disc->rports); 734 INIT_LIST_HEAD(&disc->rports);
735 735
736 disc->lport = lport; 736 disc->priv = lport;
737 737
738 return 0; 738 return 0;
739} 739}
diff --git a/drivers/scsi/libfc/fc_libfc.h b/drivers/scsi/libfc/fc_libfc.h
index f5c0ca4b6ef8..16d2162dda1f 100644
--- a/drivers/scsi/libfc/fc_libfc.h
+++ b/drivers/scsi/libfc/fc_libfc.h
@@ -52,7 +52,7 @@ extern unsigned int fc_debug_logging;
52#define FC_DISC_DBG(disc, fmt, args...) \ 52#define FC_DISC_DBG(disc, fmt, args...) \
53 FC_CHECK_LOGGING(FC_DISC_LOGGING, \ 53 FC_CHECK_LOGGING(FC_DISC_LOGGING, \
54 printk(KERN_INFO "host%u: disc: " fmt, \ 54 printk(KERN_INFO "host%u: disc: " fmt, \
55 (disc)->lport->host->host_no, \ 55 fc_disc_lport(disc)->host->host_no, \
56 ##args)) 56 ##args))
57 57
58#define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \ 58#define FC_RPORT_ID_DBG(lport, port_id, fmt, args...) \
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index fcbee8c38b0c..5f64e593cca8 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -739,7 +739,7 @@ struct libfc_function_template {
739 * @buf_len: Length of the discovery buffer 739 * @buf_len: Length of the discovery buffer
740 * @disc_id: Discovery ID 740 * @disc_id: Discovery ID
741 * @rports: List of discovered remote ports 741 * @rports: List of discovered remote ports
742 * @lport: The local port that discovery is for 742 * @priv: Private pointer for use by discovery code
743 * @disc_mutex: Mutex that protects the discovery context 743 * @disc_mutex: Mutex that protects the discovery context
744 * @partial_buf: Partial name buffer (if names are returned 744 * @partial_buf: Partial name buffer (if names are returned
745 * in multiple frames) 745 * in multiple frames)
@@ -755,7 +755,7 @@ struct fc_disc {
755 u16 disc_id; 755 u16 disc_id;
756 756
757 struct list_head rports; 757 struct list_head rports;
758 struct fc_lport *lport; 758 void *priv;
759 struct mutex disc_mutex; 759 struct mutex disc_mutex;
760 struct fc_gpn_ft_resp partial_buf; 760 struct fc_gpn_ft_resp partial_buf;
761 struct delayed_work disc_work; 761 struct delayed_work disc_work;
@@ -1003,6 +1003,11 @@ void fc_rport_terminate_io(struct fc_rport *);
1003 *****************************/ 1003 *****************************/
1004int fc_disc_init(struct fc_lport *); 1004int fc_disc_init(struct fc_lport *);
1005 1005
1006static inline struct fc_lport *fc_disc_lport(struct fc_disc *disc)
1007{
1008 return container_of(disc, struct fc_lport, disc);
1009}
1010
1006/* 1011/*
1007 * FCP LAYER 1012 * FCP LAYER
1008 *****************************/ 1013 *****************************/