]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.drivers/libfc-use-an-operations-struct.diff
Reenabled linux-xen and xen-image build
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.drivers / libfc-use-an-operations-struct.diff
1 From: Robert Love <robert.w.love@intel.com>
2 Subject: use an operations structure for rport callbacks
3 References: bnc #459142
4
5 This was called out for the disc callbacks in review
6 comments when submitting to linux-scsi. It needed to be
7 fixed for the rport callbacks too.
8
9 This patch also fixes some spacing in the fc_rport
10 structure definition as well as renaming the fc_lport_rport_event()
11 function to fc_lport_rport_callback() to more clearly
12 identify what it's doing.
13
14 Signed-off-by: Robert Love <robert.w.love@intel.com>
15 Acked-by: Bernhard Walle <bwalle@suse.de>
16 ---
17
18 drivers/scsi/libfc/fc_disc.c | 18 +++++++++-----
19 drivers/scsi/libfc/fc_lport.c | 16 ++++++++-----
20 drivers/scsi/libfc/fc_rport.c | 19 +++++++--------
21 include/scsi/libfc.h | 51 ++++++++++++++++++++++--------------------
22 4 files changed, 57 insertions(+), 47 deletions(-)
23
24
25 --- a/drivers/scsi/libfc/fc_disc.c
26 +++ b/drivers/scsi/libfc/fc_disc.c
27 @@ -154,7 +154,7 @@ void fc_disc_stop_rports(struct fc_disc
28 }
29
30 /**
31 - * fc_disc_rport_event - Event handler for rport events
32 + * fc_disc_rport_callback - Event handler for rport events
33 * @lport: The lport which is receiving the event
34 * @rport: The rport which the event has occured on
35 * @event: The event that occured
36 @@ -162,9 +162,9 @@ void fc_disc_stop_rports(struct fc_disc
37 * Locking Note: The rport lock should not be held when calling
38 * this function.
39 */
40 -static void fc_disc_rport_event(struct fc_lport *lport,
41 - struct fc_rport *rport,
42 - enum fc_lport_event event)
43 +static void fc_disc_rport_callback(struct fc_lport *lport,
44 + struct fc_rport *rport,
45 + enum fc_rport_event event)
46 {
47 struct fc_rport_libfc_priv *rdata = rport->dd_data;
48 struct fc_disc *disc = lport->disc;
49 @@ -420,6 +420,10 @@ static void fc_disc_start(void (*disc_ca
50 mutex_unlock(&disc->disc_mutex);
51 }
52
53 +static struct fc_rport_operations fc_disc_rport_ops = {
54 + .event_callback = fc_disc_rport_callback,
55 +};
56 +
57 /**
58 * fc_disc_new_target - Handle new target found by discovery
59 * @lport: FC local port
60 @@ -475,7 +479,7 @@ static int fc_disc_new_target(struct fc_
61 }
62 if (rport) {
63 rp = rport->dd_data;
64 - rp->event_callback = fc_disc_rport_event;
65 + rp->ops = &fc_disc_rport_ops;
66 rp->rp_state = RPORT_ST_INIT;
67 lport->tt.rport_login(rport);
68 }
69 @@ -658,7 +662,7 @@ static int fc_disc_gpn_ft_parse(struct f
70 rport = fc_rport_rogue_create(&dp);
71 if (rport) {
72 rdata = rport->dd_data;
73 - rdata->event_callback = fc_disc_rport_event;
74 + rdata->ops = &fc_disc_rport_ops;
75 rdata->local_port = lport;
76 lport->tt.rport_login(rport);
77 } else
78 @@ -812,7 +816,7 @@ static void fc_disc_single(struct fc_dis
79 new_rport = fc_rport_rogue_create(dp);
80 if (new_rport) {
81 rdata = new_rport->dd_data;
82 - rdata->event_callback = fc_disc_rport_event;
83 + rdata->ops = &fc_disc_rport_ops;
84 kfree(dp);
85 lport->tt.rport_login(new_rport);
86 }
87 --- a/drivers/scsi/libfc/fc_lport.c
88 +++ b/drivers/scsi/libfc/fc_lport.c
89 @@ -38,7 +38,7 @@
90 * hold the rport's mutex, but not the other way around.
91 *
92 * The only complication to this rule is the callbacks from the rport to
93 - * the lport's event_callback function. When rports become READY they make
94 + * the lport's rport_callback function. When rports become READY they make
95 * a callback to the lport so that it can track them. In the case of the
96 * directory server that callback might cause the lport to change its
97 * state, implying that the lport mutex would need to be held. This problem
98 @@ -125,7 +125,7 @@ static int fc_frame_drop(struct fc_lport
99 }
100
101 /**
102 - * fc_lport_rport_event - Event handler for rport events
103 + * fc_lport_rport_callback - Event handler for rport events
104 * @lport: The lport which is receiving the event
105 * @rport: The rport which the event has occured on
106 * @event: The event that occured
107 @@ -133,9 +133,9 @@ static int fc_frame_drop(struct fc_lport
108 * Locking Note: The rport lock should not be held when calling
109 * this function.
110 */
111 -static void fc_lport_rport_event(struct fc_lport *lport,
112 - struct fc_rport *rport,
113 - enum fc_lport_event event)
114 +static void fc_lport_rport_callback(struct fc_lport *lport,
115 + struct fc_rport *rport,
116 + enum fc_rport_event event)
117 {
118 FC_DEBUG_LPORT("Received a %d event for port (%6x)\n", event,
119 rport->port_id);
120 @@ -1265,6 +1265,10 @@ static void fc_lport_enter_rpn_id(struct
121 fc_lport_error(lport, fp);
122 }
123
124 +static struct fc_rport_operations fc_lport_rport_ops = {
125 + .event_callback = fc_lport_rport_callback,
126 +};
127 +
128 /**
129 * fc_rport_enter_dns - Create a rport to the name server
130 * @lport: Fibre Channel local port requesting a rport for the name server
131 @@ -1294,7 +1298,7 @@ static void fc_lport_enter_dns(struct fc
132 goto err;
133
134 rdata = rport->dd_data;
135 - rdata->event_callback = fc_lport_rport_event;
136 + rdata->ops = &fc_lport_rport_ops;
137 lport->tt.rport_login(rport);
138 return;
139
140 --- a/drivers/scsi/libfc/fc_rport.c
141 +++ b/drivers/scsi/libfc/fc_rport.c
142 @@ -125,7 +125,7 @@ struct fc_rport *fc_rport_rogue_create(s
143 rdata->rp_state = RPORT_ST_INIT;
144 rdata->event = RPORT_EV_NONE;
145 rdata->flags = FC_RP_FLAGS_REC_SUPPORTED;
146 - rdata->event_callback = NULL;
147 + rdata->ops = NULL;
148 rdata->e_d_tov = dp->lp->e_d_tov;
149 rdata->r_a_tov = dp->lp->r_a_tov;
150 INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
151 @@ -216,16 +216,15 @@ static void fc_rport_work(struct work_st
152 {
153 struct fc_rport_libfc_priv *rdata =
154 container_of(work, struct fc_rport_libfc_priv, event_work);
155 - enum fc_lport_event event;
156 + enum fc_rport_event event;
157 enum fc_rport_trans_state trans_state;
158 struct fc_lport *lport = rdata->local_port;
159 - void (*event_callback)(struct fc_lport *, struct fc_rport *,
160 - enum fc_lport_event);
161 + struct fc_rport_operations *rport_ops;
162 struct fc_rport *rport = PRIV_TO_RPORT(rdata);
163
164 mutex_lock(&rdata->rp_mutex);
165 event = rdata->event;
166 - event_callback = rdata->event_callback;
167 + rport_ops = rdata->ops;
168
169 if (event == RPORT_EV_CREATED) {
170 struct fc_rport *new_rport;
171 @@ -250,7 +249,7 @@ static void fc_rport_work(struct work_st
172 new_rdata = new_rport->dd_data;
173 new_rdata->e_d_tov = rdata->e_d_tov;
174 new_rdata->r_a_tov = rdata->r_a_tov;
175 - new_rdata->event_callback = rdata->event_callback;
176 + new_rdata->ops = rdata->ops;
177 new_rdata->local_port = rdata->local_port;
178 new_rdata->flags = FC_RP_FLAGS_REC_SUPPORTED;
179 new_rdata->trans_state = FC_PORTSTATE_REAL;
180 @@ -269,15 +268,15 @@ static void fc_rport_work(struct work_st
181 fc_rport_rogue_destroy(rport);
182 rport = new_rport;
183 rdata = new_rport->dd_data;
184 - if (event_callback)
185 - event_callback(lport, rport, event);
186 + if (rport_ops->event_callback)
187 + rport_ops->event_callback(lport, rport, event);
188 } else if ((event == RPORT_EV_FAILED) ||
189 (event == RPORT_EV_LOGO) ||
190 (event == RPORT_EV_STOP)) {
191 trans_state = rdata->trans_state;
192 mutex_unlock(&rdata->rp_mutex);
193 - if (event_callback)
194 - event_callback(lport, rport, event);
195 + if (rport_ops->event_callback)
196 + rport_ops->event_callback(lport, rport, event);
197 if (trans_state == FC_PORTSTATE_ROGUE)
198 fc_rport_rogue_destroy(rport);
199 else
200 --- a/include/scsi/libfc.h
201 +++ b/include/scsi/libfc.h
202 @@ -89,14 +89,6 @@ enum fc_disc_event {
203 DISC_EV_FAILED
204 };
205
206 -enum fc_lport_event {
207 - RPORT_EV_NONE = 0,
208 - RPORT_EV_CREATED,
209 - RPORT_EV_FAILED,
210 - RPORT_EV_STOP,
211 - RPORT_EV_LOGO
212 -};
213 -
214 enum fc_rport_state {
215 RPORT_ST_NONE = 0,
216 RPORT_ST_INIT, /* initialized */
217 @@ -126,6 +118,19 @@ struct fc_disc_port {
218 struct work_struct rport_work;
219 };
220
221 +enum fc_rport_event {
222 + RPORT_EV_NONE = 0,
223 + RPORT_EV_CREATED,
224 + RPORT_EV_FAILED,
225 + RPORT_EV_STOP,
226 + RPORT_EV_LOGO
227 +};
228 +
229 +struct fc_rport_operations {
230 + void (*event_callback)(struct fc_lport *, struct fc_rport *,
231 + enum fc_rport_event);
232 +};
233 +
234 /**
235 * struct fc_rport_libfc_priv - libfc internal information about a remote port
236 * @local_port: Fibre Channel host port instance
237 @@ -140,24 +145,22 @@ struct fc_disc_port {
238 * @event_callback: Callback for rport READY, FAILED or LOGO
239 */
240 struct fc_rport_libfc_priv {
241 - struct fc_lport *local_port;
242 - enum fc_rport_state rp_state;
243 - u16 flags;
244 + struct fc_lport *local_port;
245 + enum fc_rport_state rp_state;
246 + u16 flags;
247 #define FC_RP_FLAGS_REC_SUPPORTED (1 << 0)
248 #define FC_RP_FLAGS_RETRY (1 << 1)
249 - u16 max_seq;
250 - unsigned int retries;
251 - unsigned int e_d_tov;
252 - unsigned int r_a_tov;
253 - enum fc_rport_trans_state trans_state;
254 - struct mutex rp_mutex;
255 - struct delayed_work retry_work;
256 - enum fc_lport_event event;
257 - void (*event_callback)(struct fc_lport *,
258 - struct fc_rport *,
259 - enum fc_lport_event);
260 - struct list_head peers;
261 - struct work_struct event_work;
262 + u16 max_seq;
263 + unsigned int retries;
264 + unsigned int e_d_tov;
265 + unsigned int r_a_tov;
266 + enum fc_rport_trans_state trans_state;
267 + struct mutex rp_mutex;
268 + struct delayed_work retry_work;
269 + enum fc_rport_event event;
270 + struct fc_rport_operations *ops;
271 + struct list_head peers;
272 + struct work_struct event_work;
273 };
274
275 #define PRIV_TO_RPORT(x) \