fc transport: Add support for events
Subsystems (2)
PATCH 1/1 fc transport: Add support for events
The following patch adds support for hbaapi events within the FC transport. It adds the following attributes to the fc_host:
max_events : sizes the internal array for the number of events that are
buffered in the transport. This value can be tuned by a module parameter.
event_cnt : number of events pending in the buffer
event : reads an event from the buffer
It adds the following routine for LLDD's to post events:
void fc_host_event_post(struct Scsi_Host *shost,
enum fc_host_event_code event_code, u32 event_data);
Not all hbaapi events are contained within the transport. Many events correspond to elements outside the fc_host, and can be serviced by normal hot-plug events, either on the fc_host, or rport. I believe I've included those events that could be posted. I've also punted on anything that has more than 1 32-bit word of data - which should only affect RLIR payloads, and vendor-unique payloads. We will address these items once we figure out how to deal with large payloads in the transport.
In conjunction with the event infrastructure, the module uses hot plug events to notify user entities about changes. For the fc_host, the only event posted is a KOBJ_CHANGE event. For the rport, ONLINE/OFFLINE is posted whenever the rport goes through a block, then unblock. To get to the class_device for the rport, a new attribute_container function is added locate the class_device for the device.
This implementation expects the user-space hbaapi provider to deal with multiple user-space readers.
I've coordinated with Andrew Vasquez, who has sent his approval.
The lpfc driver will be posted shortly to utilize this infrastructure.
-- james s
drivers/base/attribute_container.c +42 -0
@@ -239,6 +239,48 @@ attribute_container_remove_device(structEXPORT_SYMBOL_GPL (attribute_container_remove_device);/** +* attribute_container_dev_to_classdev - see if any container is interested +* in dev +* +* @dev: device match on +* @fn: function to trigger addition of class device. +* +* This function searches the attribute containers to find the indicated +* device, and returns the classdevice associated with it. +*/ +struct class_device * +attribute_container_dev_to_classdev (struct device *dev) +{ +struct attribute_container *cont; +struct class_device *cdev =NULL ; + +down (&attribute_container_mutex); +list_for_each_entry (cont, &attribute_container_list, node) { +struct internal_container *ic; +struct klist_iter iter; + +if (!cont->match (cont, dev)) +continue ; + +if (attribute_container_no_classdevs (cont)) +continue ; + +klist_for_each_entry (ic, &cont->containers, node, &iter) { +if (dev == ic->classdev.dev) { + cdev = &ic->classdev; +break ; + } + } +if (cdev) +break ; + } +up (&attribute_container_mutex); + +return cdev; +} +EXPORT_SYMBOL_GPL (attribute_container_dev_to_classdev); + +/** * attribute_container_device_trigger - execute a trigger for each matching
classdev
*
* @dev: The generic device to run the trigger for
drivers/scsi/scsi_transport_fc.c +287 -21
398 lines not on this page · raw message
include/linux/attribute_container.h +1 -0
@@ -50,6 +50,7 @@ void attribute_container_remove_device(svoid (*fn)(struct attribute_container *,struct device *, struct class_device *)); +struct class_device *attribute_container_dev_to_classdev (struct device *dev); void attribute_container_device_trigger(struct device *dev, int (*fn)(struct attribute_container *, struct device *,
include/scsi/scsi_transport_fc.h +58 -0
109 lines not on this page · raw message
Quoted 34 lines · James Smart
The following patch adds support for hbaapi events within the FC transport. It adds the following attributes to the
fc_host:
max_events: sizes the internal array for the number of events that are
buffered in the transport. This value can be tuned by a module parameter.
event_cnt: number of events pending in the buffer
event : reads an event from the bufferIt adds the following routine for LLDD's to post events:
void fc_host_event_post(structScsi_Host*shost,enum fc_host_event_code event_code, u32 event_data);Not all hbaapi events are contained within the transport. Many events correspond to elements outside the
fc_host, and can be serviced by normal hot-plug events, either on thefc_host, or rport. I believe I've included those events that could be posted. I've also punted on anything that has more
than 1 32-bit word of data - which should only affect RLIR payloads, and vendor-unique payloads. We will address these items once we figure out how to deal with large payloads in the transport.In conjunction with the event infrastructure, the module uses hot plug events
to notify user entities about changes. For thefc_host, the only event posted
is aKOBJ_CHANGEevent. For the rport, ONLINE/OFFLINE is posted whenever the
rport goes through a block, then unblock. To get to theclass_devicefor the
rport, a newattribute_containerfunction is added locate theclass_devicefor
the device.
Quoted 6 lines
This implementation expects the user-space hbaapi provider to deal with multiple user-space readers.
I've coordinated with Andrew Vasquez, who has sent his approval.
The lpfc driver will be posted shortly to utilize this infrastructure.
I must admit I don't like this too much. The natural way to send events to userspace would be a netlink socket, but integrating this with the transport class might be a bit hard. Having named netlink sockets similar to named unix sockets would be nice for this..
It would have been nice to have had this response on the RFC.
I'm actually looking into netlink for the CT pass thru, ELS and rnid functions.
Does it make sense to move forward with some event support - namely the events attributes minus the kobject_uevent() stuff ?
-- james
Quoted 39 lines · Christoph Hellwig
Quoted 27 lines · James Smart
The following patch adds support for hbaapi events within the FC transport. It adds the following attributes to the
fc_host:
max_events: sizes the internal array for the number of events that are
buffered in the transport. This value can be tuned by a module parameter.
event_cnt: number of events pending in the buffer
event : reads an event from the bufferIt adds the following routine for LLDD's to post events:
void fc_host_event_post(structScsi_Host*shost,enum fc_host_event_code event_code, u32 event_data);Not all hbaapi events are contained within the transport. Many events correspond to elements outside the
fc_host, and can be serviced by normal hot-plug events, either on thefc_host, or rport. I believe I've included those events that could be posted. I've also punted on anything that has more than 1 32-bit word of data - which should only affect RLIR payloads, and vendor-unique payloads. We will address these items once we figure out how to deal with large payloads in the transport.In conjunction with the event infrastructure, the module uses hot plug events to notify user entities about changes. For the
fc_host, the only event posted is aKOBJ_CHANGEevent. For the rport, ONLINE/OFFLINE is posted whenever the rport goes through a block, then unblock. To get to theclass_devicefor the rport, a newattribute_containerfunction is added locate theclass_devicefor the device.Quoted 6 lines
This implementation expects the user-space hbaapi provider to deal with multiple user-space readers.
I've coordinated with Andrew Vasquez, who has sent his approval.
The lpfc driver will be posted shortly to utilize this infrastructure.
I must admit I don't like this too much. The natural way to send events to userspace would be a netlink socket, but integrating this with the transport class might be a bit hard. Having named netlink sockets similar to named unix sockets would be nice for this..
Quoted 7 lines · James Smart
It would have been nice to have had this response on the RFC.
I'm actually looking into netlink for the CT pass thru, ELS and rnid functions.
Does it make sense to move forward with some event support - namely the events attributes minus the
kobject_uevent()stuff ?
Actually the events attributes are what I don't like at all. kobject_uevent already is a wrapper around netlink, it just doesn't allow to transport all the nessecary data.
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · James Smart
It would have been nice to have had this response on the RFC.
I'm actually looking into netlink for the CT pass thru, ELS and rnid functions.
Quoted 7 lines
Quoted 2 lines
Does it make sense to move forward with some event support - namely the events attributes minus the
kobject_uevent()stuff ?Actually the events attributes are what I don't like at all.
kobject_ueventalready is a wrapper around netlink, it just doesn't allow to transport all the nessecary data.
The scsi_transport_iscsi.c already contains the netlink infrastructure. Maybe some of this code could be shared between the transports.
I derived another implementation off the iscsi transport code for dm that uses the netlink attribute support.
https://www.redhat.com/archives/dm-devel/2006-February/msg00024.html
-andmike
--
Michael Anderson
[email protected]