diff options
Diffstat (limited to 'runtime/transport')
-rw-r--r-- | runtime/transport/ChangeLog | 14 | ||||
-rw-r--r-- | runtime/transport/control.h | 1 | ||||
-rw-r--r-- | runtime/transport/transport.c | 62 | ||||
-rw-r--r-- | runtime/transport/transport.h | 41 |
4 files changed, 90 insertions, 28 deletions
diff --git a/runtime/transport/ChangeLog b/runtime/transport/ChangeLog index 8f9cccfe..72a6e7ae 100644 --- a/runtime/transport/ChangeLog +++ b/runtime/transport/ChangeLog @@ -1,3 +1,17 @@ +2005-06-20 Tom Zanussi <zanussi@us.ibm.com> + + * control.h: Added STP_TRANSPORT_MODE command. + + * transport.c: Lots of changes, most importantly + added transport mode command, which also sends buffer + sizes to daemon, added limit to number of attempts to + sending STP_EXIT (in case there is no daemon), moved + exit helper call. + + * transport.h: Added transport type enum and transport + info struct for communication with userspace, changed and + moved a couple functions to transport.c. + 2005-05-17 Martin Hunt <hunt@redhat.com> * transport.c (_stp_transport_close): Call stp_exit_helper() diff --git a/runtime/transport/control.h b/runtime/transport/control.h index a614ecb7..f4e326da 100644 --- a/runtime/transport/control.h +++ b/runtime/transport/control.h @@ -22,6 +22,7 @@ enum STP_BUF_INFO = 1, STP_SUBBUFS_CONSUMED, STP_REALTIME_DATA, + STP_TRANSPORT_MODE, STP_EXIT, }; diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index 8ce97bff..5645fe3b 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -38,6 +38,17 @@ struct stp_transport *t; static void probe_exit(void); /** + * _stp_streaming - boolean, are we using 'streaming' output? + */ +static inline int _stp_streaming(void) +{ + if (t->transport_mode == STP_TRANSPORT_NETLINK) + return 1; + + return 0; +} + +/** * _stp_handle_buf_info - handle relayfs buffer info command */ static void _stp_handle_buf_info(int pid, struct buf_info *in) @@ -61,16 +72,47 @@ static void _stp_handle_subbufs_consumed(int pid, struct consumed_info *info) relay_subbufs_consumed(t->chan, info->cpu, info->consumed); } +/** + * _stp_handle_subbufs_consumed - handle relayfs subbufs consumed command + */ +static void _stp_handle_transport(int pid) +{ + struct transport_info out; + BUG_ON(!(t)); + + out.transport_mode = t->transport_mode; + if (t->transport_mode == STP_TRANSPORT_RELAYFS) { + out.subbuf_size = subbuf_size; + out.n_subbufs = n_subbufs; + } + + _stp_ctrl_send(STP_TRANSPORT_MODE, &out, sizeof(out), pid); +} + int _stp_exit_called = 0; static int global_pid; static void stp_exit_helper (void *data); static DECLARE_WORK(stp_exit, stp_exit_helper, &global_pid); +/** + * _stp_transport_flush - flush the transport, if applicable + */ +static inline void _stp_transport_flush(void) +{ + extern struct stp_transport *t; + + if (t->transport_mode == STP_TRANSPORT_RELAYFS) { + BUG_ON(!t->chan); + relay_flush(t->chan); + ssleep(1); /* FIXME: time for data to be flushed */ + } +} + extern atomic_t _stp_transport_failures; static void stp_exit_helper (void *data) { - int err, pid = *(int *)data; + int err, trylimit = 50, pid = *(int *)data; if (_stp_exit_called == 0) { _stp_exit_called = 1; @@ -78,11 +120,12 @@ static void stp_exit_helper (void *data) _stp_transport_flush(); } - //printk("stp_handle_exit: sending STP_EXIT. pid=%d\n",(int)pid); while ((err =_stp_ctrl_send(STP_EXIT, __this_module.name, strlen(__this_module.name) + 1, pid)) < 0) { //printk("stp_handle_exit: sent STP_EXIT. err=%d\n", err); msleep (5); + if (!trylimit--) /* limit e.g. if user died */ + break; } } @@ -106,6 +149,9 @@ static int _stp_cmd_handler(int pid, int cmd, void *data) case STP_SUBBUFS_CONSUMED: _stp_handle_subbufs_consumed(pid, data); break; + case STP_TRANSPORT_MODE: + _stp_handle_transport(pid); + break; case STP_EXIT: schedule_work (&stp_exit); break; @@ -128,11 +174,13 @@ void _stp_transport_close() if (!t) return; + stp_exit_helper (&t->pid); + _stp_ctrl_unregister(t->pid); if (!_stp_streaming()) _stp_relayfs_close(t->chan, t->dir); - stp_exit_helper (&t->pid); +// stp_exit_helper (&t->pid); kfree(t); } @@ -149,7 +197,10 @@ void _stp_transport_close() * relayfs channel for it. This must be called before any I/O is * done, probably at the start of module initialization. */ -int _stp_transport_open(unsigned n_subbufs, unsigned subbuf_size, int pid) +int _stp_transport_open(int transport_mode, + unsigned n_subbufs, + unsigned subbuf_size, + int pid) { BUG_ON(!(n_subbufs && subbuf_size)); @@ -161,6 +212,8 @@ int _stp_transport_open(unsigned n_subbufs, unsigned subbuf_size, int pid) global_pid = pid; _stp_ctrl_register(t->pid, _stp_cmd_handler); + t->transport_mode = transport_mode; + if (_stp_streaming()) return 0; @@ -185,5 +238,6 @@ int _stp_transport_send (int pid, void *data, int len) } return err; } + /** @} */ #endif /* _TRANSPORT_C_ */ diff --git a/runtime/transport/transport.h b/runtime/transport/transport.h index a20ba8d8..9e98c894 100644 --- a/runtime/transport/transport.h +++ b/runtime/transport/transport.h @@ -9,11 +9,19 @@ #include "netlink.h" #include "relayfs.h" +/* SystemTap transport values */ +enum +{ + STP_TRANSPORT_NETLINK = 1, + STP_TRANSPORT_RELAYFS +}; + /* transport data structure */ struct stp_transport { struct rchan *chan; struct dentry *dir; + int transport_mode; int pid; }; @@ -31,6 +39,12 @@ struct consumed_info unsigned consumed; }; +struct transport_info +{ + int transport_mode; + unsigned subbuf_size; + unsigned n_subbufs; +}; /** * _stp_transport_write - write data to the transport @@ -44,30 +58,9 @@ struct consumed_info #define _stp_transport_write(t, data, len) relay_write(t->chan, data, len) #endif -/** - * _stp_streaming - boolean, are we using 'streaming' output? - */ -#ifdef STP_NETLINK_ONLY -#define _stp_streaming() (1) -#else -#define _stp_streaming() (0) -#endif - -/** - * _stp_transport_flush - flush the transport, if applicable - */ -static inline void _stp_transport_flush(void) -{ -#ifndef STP_NETLINK_ONLY - extern struct stp_transport *t; - - BUG_ON(!t->chan); - relay_flush(t->chan); - ssleep(1); /* FIXME: time for data to be flushed */ -#endif -} - -extern int _stp_transport_open(unsigned n_subbufs, unsigned subbuf_size, +extern int _stp_transport_open(int transport_mode, + unsigned n_subbufs, + unsigned subbuf_size, int pid); extern void _stp_transport_close(void); extern int _stp_transport_send (int pid, void *data, int len); |