mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-14 09:11:27 +00:00
SCST events infrastructure
Prepared with help from Prasidh Srikanth <Prasidh.Srikanth@sandisk.com> git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6574 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
131
scst/include/scst_event.h
Normal file
131
scst/include/scst_event.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* include/scst_event.h
|
||||
*
|
||||
* Copyright (C) 2014 - 2015 SanDisk Corporation
|
||||
*
|
||||
* Contains constants and data structures for scst_event module.
|
||||
*/
|
||||
|
||||
#ifndef __SCST_EVENT_H
|
||||
#define __SCST_EVENT_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef INSIDE_KERNEL_TREE
|
||||
#include <scst/scst_const.h>
|
||||
#else
|
||||
#include "scst_const.h"
|
||||
#endif
|
||||
|
||||
#define SCST_EVENT_NAME "scst_event"
|
||||
#define SCST_EVENT_PATH "/dev/"
|
||||
#define SCST_EVENT_DEV SCST_EVENT_PATH SCST_EVENT_NAME
|
||||
#define SCST_EVENT_VERSION_NAME SCST_VERSION_NAME
|
||||
#define SCST_EVENT_VERSION \
|
||||
SCST_EVENT_VERSION_NAME "$Revision: 2454 $" SCST_CONST_VERSION
|
||||
|
||||
#ifndef aligned_u64
|
||||
#define aligned_u64 uint64_t __attribute__((aligned(8)))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Due to variable size, this structure must always be last in any outer
|
||||
* structure!
|
||||
*/
|
||||
struct scst_event {
|
||||
int32_t payload_len;
|
||||
|
||||
uint32_t event_code;
|
||||
|
||||
uint32_t event_id; /* ID uniquely identifying this event */
|
||||
|
||||
/*
|
||||
* Event's issuer's name, i.e. SCST name of the corresponding module
|
||||
* (target driver or dev handler). SCST_EVENT_SCST_CORE_ISSUER for SCST
|
||||
* core.
|
||||
*/
|
||||
char issuer_name[SCST_MAX_NAME];
|
||||
|
||||
uint8_t payload[]; /* event's payload */
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
typedef void (*scst_event_done_notify_fn) (struct scst_event *event,
|
||||
void *priv, int status);
|
||||
|
||||
struct scst_event_entry {
|
||||
struct list_head events_list_entry;
|
||||
scst_event_done_notify_fn event_notify_fn;
|
||||
void *notify_fn_priv;
|
||||
unsigned long event_timeout; /* in jiffies */
|
||||
int *pqueued_events_cnt;
|
||||
union {
|
||||
struct work_struct scst_event_queue_work;
|
||||
struct delayed_work event_timeout_work;
|
||||
};
|
||||
|
||||
struct scst_event event;
|
||||
/* event's payload */
|
||||
};
|
||||
#endif
|
||||
|
||||
struct scst_event_user {
|
||||
int32_t max_event_size;
|
||||
struct scst_event out_event;
|
||||
};
|
||||
|
||||
struct scst_event_notify_done {
|
||||
uint32_t event_id;
|
||||
int status;
|
||||
};
|
||||
|
||||
/* IOCTLs */
|
||||
#define SCST_EVENT_ALLOW_EVENT _IOW('u', 1, struct scst_event)
|
||||
#define SCST_EVENT_DISALLOW_EVENT _IOW('u', 2, struct scst_event)
|
||||
#define SCST_EVENT_GET_NEXT_EVENT _IOWR('u', 3, struct scst_event_user)
|
||||
#define SCST_EVENT_NOTIFY_DONE _IOW('u', 4, struct scst_event_notify_done)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
void scst_event_queue(uint32_t event_code, const char *issuer_name,
|
||||
struct scst_event_entry *e);
|
||||
#endif
|
||||
|
||||
/*************************************************************
|
||||
** SCST events
|
||||
*************************************************************/
|
||||
|
||||
/* SCST core issuer name */
|
||||
#define SCST_EVENT_SCST_CORE_ISSUER "SCST core"
|
||||
|
||||
/** SCST core's events **/
|
||||
|
||||
#define SCST_EVENT_LUN_NOT_FOUND 1
|
||||
struct scst_event_lun_not_found_payload {
|
||||
aligned_u64 lun;
|
||||
uint8_t initiator_name[SCST_MAX_EXTERNAL_NAME];
|
||||
uint8_t target_name[SCST_MAX_EXTERNAL_NAME];
|
||||
};
|
||||
|
||||
#define SCST_EVENT_NEGATIVE_LUNS_INQUIRY 2
|
||||
struct scst_event_negative_luns_inquiry_payload {
|
||||
uint8_t initiator_name[SCST_MAX_EXTERNAL_NAME];
|
||||
uint8_t target_name[SCST_MAX_EXTERNAL_NAME];
|
||||
};
|
||||
|
||||
#define SCST_EVENT_TM_FN_RECEIVED 4
|
||||
struct scst_event_tm_fn_received_payload {
|
||||
uint32_t fn; /* TM fn */
|
||||
aligned_u64 lun;
|
||||
uint8_t device_name[SCST_MAX_EXTERNAL_NAME];
|
||||
uint8_t initiator_name[SCST_MAX_EXTERNAL_NAME];
|
||||
uint8_t target_name[SCST_MAX_EXTERNAL_NAME];
|
||||
uint8_t session_sysfs_name[SCST_MAX_EXTERNAL_NAME];
|
||||
struct { /* if ABORT TASK, then tag and CDB of cmd to abort */
|
||||
aligned_u64 cmd_to_abort_tag;
|
||||
uint8_t cdb[SCST_MAX_CDB_SIZE];
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* __SCST_EVENT_H */
|
||||
@@ -56,6 +56,7 @@ ifdef CONFIG_DLM_MODULE
|
||||
scst-y += scst_dlm.o
|
||||
endif
|
||||
scst-y += scst_tg.o
|
||||
scst-y += scst_event.o
|
||||
obj-$(CONFIG_SCST) += scst.o dev_handlers/
|
||||
|
||||
obj-$(BUILD_DEV) += $(DEV_HANDLERS_DIR)/
|
||||
|
||||
1066
scst/src/scst_event.c
Normal file
1066
scst/src/scst_event.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2582,10 +2582,14 @@ static int __init init_scst(void)
|
||||
goto out_destroy_sense_mempool;
|
||||
}
|
||||
|
||||
res = scst_sysfs_init();
|
||||
res = scst_event_init();
|
||||
if (res != 0)
|
||||
goto out_destroy_aen_mempool;
|
||||
|
||||
res = scst_sysfs_init();
|
||||
if (res != 0)
|
||||
goto out_event_exit;
|
||||
|
||||
scst_tg_init();
|
||||
|
||||
if (scst_max_cmd_mem == 0) {
|
||||
@@ -2682,6 +2686,9 @@ out_destroy_sgv_pool:
|
||||
out_sysfs_cleanup:
|
||||
scst_sysfs_cleanup();
|
||||
|
||||
out_event_exit:
|
||||
scst_event_exit();
|
||||
|
||||
out_destroy_aen_mempool:
|
||||
mempool_destroy(scst_aen_mempool);
|
||||
|
||||
@@ -2763,6 +2770,8 @@ static void __exit exit_scst(void)
|
||||
|
||||
scst_sysfs_cleanup();
|
||||
|
||||
scst_event_exit();
|
||||
|
||||
#define DEINIT_CACHEP(p) do { \
|
||||
kmem_cache_destroy(p); \
|
||||
p = NULL; \
|
||||
|
||||
@@ -851,6 +851,14 @@ int gen_relative_target_port_id(uint16_t *id);
|
||||
bool scst_is_relative_target_port_id_unique(uint16_t id,
|
||||
const struct scst_tgt *t);
|
||||
|
||||
int scst_event_init(void);
|
||||
void scst_event_exit(void);
|
||||
|
||||
int scst_event_queue_lun_not_found(const struct scst_cmd *cmd);
|
||||
int scst_event_queue_negative_luns_inquiry(const struct scst_tgt *tgt,
|
||||
const char *initiator_name);
|
||||
int scst_event_queue_tm_fn_received(struct scst_mgmt_cmd *mcmd);
|
||||
|
||||
typedef void __printf(2, 3) (*scst_show_fn)(void *arg, const char *fmt, ...);
|
||||
void scst_trace_cmds(scst_show_fn show, void *arg);
|
||||
void scst_trace_mcmds(scst_show_fn show, void *arg);
|
||||
|
||||
Reference in New Issue
Block a user