aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc/fc_libfc.c
diff options
context:
space:
mode:
authorJoe Eykholt <jeykholt@cisco.com>2011-01-28 19:04:18 -0500
committerJames Bottomley <James.Bottomley@suse.de>2011-02-12 12:02:20 -0500
commit70d53b046a6221e3ceb3bd8eaa807ef6a1c53762 (patch)
treef1ab4e0de20a8db091ea04df564a03a689698b40 /drivers/scsi/libfc/fc_libfc.c
parentbaf9fdf076a8976431b5de565aef2b98816caecf (diff)
[SCSI] libfc: add hook to notify providers of local port changes
When an SCST provider is registered, it needs to know what local ports are available for configuration as targets. Add a notifier chain that is invoked when any local port that is added or deleted. Maintain a global list of local ports and add an interator function that calls a given function for every existing local port. This is used when first loading a provider. 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>
Diffstat (limited to 'drivers/scsi/libfc/fc_libfc.c')
-rw-r--r--drivers/scsi/libfc/fc_libfc.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/scsi/libfc/fc_libfc.c b/drivers/scsi/libfc/fc_libfc.c
index ae3abef6523e..5e40dab8f919 100644
--- a/drivers/scsi/libfc/fc_libfc.c
+++ b/drivers/scsi/libfc/fc_libfc.c
@@ -36,6 +36,10 @@ module_param_named(debug_logging, fc_debug_logging, int, S_IRUGO|S_IWUSR);
36MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); 36MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels");
37 37
38DEFINE_MUTEX(fc_prov_mutex); 38DEFINE_MUTEX(fc_prov_mutex);
39static LIST_HEAD(fc_local_ports);
40struct blocking_notifier_head fc_lport_notifier_head =
41 BLOCKING_NOTIFIER_INIT(fc_lport_notifier_head);
42EXPORT_SYMBOL(fc_lport_notifier_head);
39 43
40/* 44/*
41 * Providers which primarily send requests and PRLIs. 45 * Providers which primarily send requests and PRLIs.
@@ -228,6 +232,17 @@ void fc_fill_reply_hdr(struct fc_frame *fp, const struct fc_frame *in_fp,
228} 232}
229EXPORT_SYMBOL(fc_fill_reply_hdr); 233EXPORT_SYMBOL(fc_fill_reply_hdr);
230 234
235void fc_lport_iterate(void (*notify)(struct fc_lport *, void *), void *arg)
236{
237 struct fc_lport *lport;
238
239 mutex_lock(&fc_prov_mutex);
240 list_for_each_entry(lport, &fc_local_ports, lport_list)
241 notify(lport, arg);
242 mutex_unlock(&fc_prov_mutex);
243}
244EXPORT_SYMBOL(fc_lport_iterate);
245
231/** 246/**
232 * fc_fc4_register_provider() - register FC-4 upper-level provider. 247 * fc_fc4_register_provider() - register FC-4 upper-level provider.
233 * @type: FC-4 type, such as FC_TYPE_FCP 248 * @type: FC-4 type, such as FC_TYPE_FCP
@@ -270,3 +285,29 @@ void fc_fc4_deregister_provider(enum fc_fh_type type, struct fc4_prov *prov)
270 synchronize_rcu(); 285 synchronize_rcu();
271} 286}
272EXPORT_SYMBOL(fc_fc4_deregister_provider); 287EXPORT_SYMBOL(fc_fc4_deregister_provider);
288
289/**
290 * fc_fc4_add_lport() - add new local port to list and run notifiers.
291 * @lport: The new local port.
292 */
293void fc_fc4_add_lport(struct fc_lport *lport)
294{
295 mutex_lock(&fc_prov_mutex);
296 list_add_tail(&lport->lport_list, &fc_local_ports);
297 blocking_notifier_call_chain(&fc_lport_notifier_head,
298 FC_LPORT_EV_ADD, lport);
299 mutex_unlock(&fc_prov_mutex);
300}
301
302/**
303 * fc_fc4_del_lport() - remove local port from list and run notifiers.
304 * @lport: The new local port.
305 */
306void fc_fc4_del_lport(struct fc_lport *lport)
307{
308 mutex_lock(&fc_prov_mutex);
309 list_del(&lport->lport_list);
310 blocking_notifier_call_chain(&fc_lport_notifier_head,
311 FC_LPORT_EV_DEL, lport);
312 mutex_unlock(&fc_prov_mutex);
313}