* [PATCH 8/8] fusion - mptctl -adding asyn event notification support
@ 2006-02-03 0:20 Moore, Eric
2006-02-04 11:23 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Moore, Eric @ 2006-02-03 0:20 UTC (permalink / raw)
To: linux-scsi
[-- Attachment #1: Type: text/plain, Size: 72 bytes --]
Adding aen support.
Signed-off-by: Eric Moore <Eric.Moore@lsil.com>
[-- Attachment #2: 8-aen.patch --]
[-- Type: application/octet-stream, Size: 3780 bytes --]
diff -uarN b/drivers/message/fusion/mptbase.h a/drivers/message/fusion/mptbase.h
--- b/drivers/message/fusion/mptbase.h 2006-02-02 16:00:04.000000000 -0700
+++ a/drivers/message/fusion/mptbase.h 2006-02-02 16:40:28.000000000 -0700
@@ -616,6 +616,7 @@
* increments by 32 bytes
*/
int errata_flag_1064;
+ int aen_event_read_flag; /* flag to indicate event log was read*/
u8 FirstWhoInit;
u8 upload_fw; /* If set, do a fw upload */
u8 reload_fw; /* Force a FW Reload on next reset */
diff -uarN b/drivers/message/fusion/mptctl.c a/drivers/message/fusion/mptctl.c
--- b/drivers/message/fusion/mptctl.c 2006-02-02 16:28:30.000000000 -0700
+++ a/drivers/message/fusion/mptctl.c 2006-02-02 16:42:01.000000000 -0700
@@ -136,6 +136,12 @@
*/
static int mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase);
+/*
+ * Event Handler function
+ */
+static int mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
+struct fasync_struct *async_queue=NULL;
+
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
* Scatter gather list (SGL) sizes and limits...
@@ -472,6 +478,69 @@
}
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+/* ASYNC Event Notification Support */
+static int
+mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
+{
+ u8 event;
+
+ event = le32_to_cpu(pEvReply->Event) & 0xFF;
+
+ dctlprintk(("%s() called\n", __FUNCTION__));
+ if(async_queue == NULL)
+ return 1;
+
+ /* Raise SIGIO for persistent events.
+ * TODO - this define is not in MPI spec yet,
+ * but they plan to set it to 0x21
+ */
+ if (event == 0x21 ) {
+ ioc->aen_event_read_flag=1;
+ dctlprintk(("Raised SIGIO to application\n"));
+ devtprintk(("Raised SIGIO to application\n"));
+ kill_fasync(&async_queue, SIGIO, POLL_IN);
+ return 1;
+ }
+
+ /* This flag is set after SIGIO was raised, and
+ * remains set until the application has read
+ * the event log via ioctl=MPTEVENTREPORT
+ */
+ if(ioc->aen_event_read_flag)
+ return 1;
+
+ /* Signal only for the events that are
+ * requested for by the application
+ */
+ if (ioc->events && (ioc->eventTypes & ( 1 << event))) {
+ ioc->aen_event_read_flag=1;
+ dctlprintk(("Raised SIGIO to application\n"));
+ devtprintk(("Raised SIGIO to application\n"));
+ kill_fasync(&async_queue, SIGIO, POLL_IN);
+ }
+ return 1;
+}
+
+static int
+mptctl_fasync(int fd, struct file *filep, int mode)
+{
+ MPT_ADAPTER *ioc;
+
+ list_for_each_entry(ioc, &ioc_list, list)
+ ioc->aen_event_read_flag=0;
+
+ dctlprintk(("%s() called\n", __FUNCTION__));
+ return fasync_helper(fd, filep, mode, &async_queue);
+}
+
+static int
+mptctl_release(struct inode *inode, struct file *filep)
+{
+ dctlprintk(("%s() called\n", __FUNCTION__));
+ return fasync_helper(-1, filep, 0, &async_queue);
+}
+
+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
* MPT ioctl handler
* cmd - specify the particular IOCTL command to be issued
@@ -1603,6 +1672,9 @@
if ((max < 1) || !ioc->events)
return -ENODATA;
+ /* reset this flag so SIGIO can restart */
+ ioc->aen_event_read_flag=0;
+
/* Copy the data from kernel memory to user memory
*/
numBytes = max * sizeof(MPT_IOCTL_EVENTS);
@@ -2649,6 +2721,8 @@
static struct file_operations mptctl_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
+ .release = mptctl_release,
+ .fasync = mptctl_fasync,
.unlocked_ioctl = mptctl_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_mpctl_ioctl,
@@ -2893,6 +2967,11 @@
/* FIXME! */
}
+ if (mpt_event_register(mptctl_id, mptctl_event_process) == 0) {
+ devtprintk((KERN_INFO MYNAM
+ ": Registered for IOC event notifications\n"));
+ }
+
return 0;
out_fail:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 8/8] fusion - mptctl -adding asyn event notification support
2006-02-03 0:20 [PATCH 8/8] fusion - mptctl -adding asyn event notification support Moore, Eric
@ 2006-02-04 11:23 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2006-02-04 11:23 UTC (permalink / raw)
To: Moore, Eric; +Cc: linux-scsi
On Thu, Feb 02, 2006 at 05:20:01PM -0700, Moore, Eric wrote:
> Adding aen support.
looks good, but it could use some codingstyle love:
+/*
+ * Event Handler function
+ */
+static int mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
no need for the forward prototype, the function isn't used before it's
defined.
+struct fasync_struct *async_queue=NULL;
no need to initialize this to NULL because it'll go into .bss and will
be initializes automatically. Also this variable can be static.
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+/* ASYNC Event Notification Support */
+static int
+mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
+{
+ u8 event;
+
+ event = le32_to_cpu(pEvReply->Event) & 0xFF;
+
+ dctlprintk(("%s() called\n", __FUNCTION__));
+ if(async_queue == NULL)
if (async_queue == NULL)
or even better
if (!async_queue)
+ ioc->aen_event_read_flag=1;
and please always put spaces around the '='
+static int
+mptctl_fasync(int fd, struct file *filep, int mode)
+{
+ MPT_ADAPTER *ioc;
+
+ list_for_each_entry(ioc, &ioc_list, list)
+ ioc->aen_event_read_flag=0;
doesn't this need some locking?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-04 11:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-03 0:20 [PATCH 8/8] fusion - mptctl -adding asyn event notification support Moore, Eric
2006-02-04 11:23 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).