diff --git a/.gitignore b/.gitignore index a71345eac56d9fd9f99a8b771fba2e98277efe37..4ca7ea953d96ae987cc45b642b6805626b708d76 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,10 @@ src/nds/autom4te.cache src/daqd/config/install-sh src/daqd/config/ltmain.sh src/daqd/m4 -src/daqd/autom4te.cache \ No newline at end of file +src/daqd/autom4te.cache + +# srctrl +*.srctrl* + +#kernel module build files +modules.order diff --git a/NEWS b/NEWS index d5efae48c517095a86bbf78d986503c1a865b63f..aa7fd61a242ecf5af1892a18b4890ad492de46e1 100644 --- a/NEWS +++ b/NEWS @@ -21,11 +21,11 @@ Changes for 4.0 (NOT YET RELEASED) - Increase the number of connections allowed on a daqd circular buffer past 32. - Generalize the data structure to allow changing the max number easier. Currently set to 128. - Updated the nds process - - run dir defaults to /var/run/nds + - run dir defaults to /run/nds - the name of the socket has changed from pipe to daqd_socket - the command line is changed to specifying the run dir instead of the pipe/socket filename - - ie nds --rundir /var/run/nds - - gives a jobs dir of /var/run/nds/jobs and a socket at /var/run/nds/daqd_socket + - ie nds --rundir /run/nds + - gives a jobs dir of /run/nds/jobs and a socket at /run/nds/daqd_socket - the nds process will attempt to create the 'jobs' directory if it does not exist ================================================================================================== Changes for 3.6 (NOT YET RELEASED) diff --git a/src/daqd/daqd.hh b/src/daqd/daqd.hh index 81e54385ca760dd3ee39d4a55559370fa961b44a..dbf9b3da7033105485c2dbf1fed6f7585f682c77 100644 --- a/src/daqd/daqd.hh +++ b/src/daqd/daqd.hh @@ -230,7 +230,7 @@ public: static std::string default_nds_jobs_dir( ) { - return "/var/run/nds"; + return "/run/nds"; } daqd_c( ) diff --git a/src/drv/gpstime/gpstime.c b/src/drv/gpstime/gpstime.c index c64e9e5ea773ec42250afda70af8d7f2eb28abb3..e43a9ae061de0d357bd5cc368128aad1a1678712 100644 --- a/src/drv/gpstime/gpstime.c +++ b/src/drv/gpstime/gpstime.c @@ -13,6 +13,7 @@ #include <linux/kernel.h> #include <linux/kobject.h> #include <linux/sysfs.h> +#include <linux/device.h> #include <linux/types.h> #include <linux/errno.h> @@ -52,7 +53,9 @@ atomic64_t gps_offset = ATOMIC_INIT(0); static int gps_module_sync_type = STATUS_SYMMETRICOM_NO_SYNC; /* character device structures */ -static dev_t symmetricom_dev; +static dev_t symmetricom_dev = MKDEV( 0, 0 ); +static struct class* gpstime_class = NULL; +static struct device* gpstime_device = NULL; static struct cdev symmetricom_cdev; static int card_present; static int card_type; /* 0 - symmetricom; 1 - spectracom */ @@ -308,11 +311,23 @@ static int __init symmetricom_init(void) goto out; } + if (IS_ERR(gpstime_class = class_create( THIS_MODULE, "ligo_gpstime" ))) + { + printk(KERN_ERR "could not allocate device class for gpstime\n"); + goto out_unalloc_region; + } + + if (IS_ERR(gpstime_device = device_create( gpstime_class, NULL, symmetricom_dev, NULL, "gpstime" ))) + { + printk(KERN_ERR "could not create device file for gpstime\n"); + goto out_cleanup_class; + } + /* initialize the device structure and register the device with the kernel */ cdev_init(&symmetricom_cdev, &symmetricom_fops); if ((ret = cdev_add(&symmetricom_cdev, symmetricom_dev, 1)) < 0) { printk(KERN_ERR "could not allocate chrdev for buf\n"); - goto out_unalloc_region; + goto out_cleanup_device; } // Create /proc/gps filesystem tree @@ -379,6 +394,10 @@ out_remove_proc_entry: gpstime_sysfs_dir = NULL; } remove_proc_entry("gps", NULL); +out_cleanup_device: + device_destroy( gpstime_class, symmetricom_dev ); +out_cleanup_class: + class_destroy( gpstime_class ); out_unalloc_region: unregister_chrdev_region(symmetricom_dev, 1); out: @@ -388,14 +407,15 @@ out: /* module unload */ static void __exit symmetricom_exit(void) { - /* remove the character deivce */ - cdev_del(&symmetricom_cdev); - unregister_chrdev_region(symmetricom_dev, 1); - remove_proc_entry("gps", NULL); if (gpstime_sysfs_dir != NULL) { kobject_del(gpstime_sysfs_dir); gpstime_sysfs_dir = NULL; } + remove_proc_entry("gps", NULL); + device_destroy( gpstime_class, symmetricom_dev ); + class_destroy( gpstime_class ); + cdev_del(&symmetricom_cdev); + unregister_chrdev_region(symmetricom_dev, 1); } EXPORT_SYMBOL(ligo_get_gps_driver_offset); diff --git a/src/drv/mbuf/mbuf.c b/src/drv/mbuf/mbuf.c index dd6b06079227a3ee67fef25544b53292fc51ebd3..0a45ce097c17c1a750aee2531854f4e687bb12cc 100644 --- a/src/drv/mbuf/mbuf.c +++ b/src/drv/mbuf/mbuf.c @@ -4,6 +4,7 @@ #include <linux/module.h> #include <linux/fs.h> #include <linux/cdev.h> +#include <linux/device.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/mm.h> @@ -36,7 +37,9 @@ module_param(one_fill, short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); MODULE_PARM_DESC(on_fill, "Set to 1 want to fill newly allocated memory with one bits"); /* character device structures */ -static dev_t mbuf_dev; +static dev_t mbuf_dev = MKDEV( 0, 0 ) ; +static struct class* mbuf_class = NULL; +static struct device* mbuf_device = NULL; static struct cdev mbuf_cdev; /* methods of the character device */ @@ -414,11 +417,23 @@ static int __init mbuf_init(void) goto out; } + if (IS_ERR(mbuf_class = class_create( THIS_MODULE, "ligo_mbuf" ))) + { + printk(KERN_ERR "could not allocate device class for mbuf\n"); + goto out_unalloc_region; + }; + + if (IS_ERR(mbuf_device = device_create( mbuf_class, NULL, mbuf_dev, NULL, "mbuf" ))) + { + printk(KERN_ERR "could not create device file for mbuf\n"); + goto out_cleanup_class; + } + /* initialize the device structure and register the device with the kernel */ cdev_init(&mbuf_cdev, &mbuf_fops); if ((ret = cdev_add(&mbuf_cdev, mbuf_dev, 1)) < 0) { printk(KERN_ERR "could not allocate chrdev for buf\n"); - goto out_unalloc_region; + goto out_cleanup_device; } mbuf_sysfs_dir = kobject_create_and_add("mbuf", kernel_kobj); @@ -442,7 +457,11 @@ static int __init mbuf_init(void) return ret; out_remove_sysfs: - kobject_del(mbuf_sysfs_dir); + kobject_del(mbuf_sysfs_dir); + out_cleanup_device: + device_destroy( mbuf_class, mbuf_dev ); + out_cleanup_class: + class_destroy( mbuf_class ); out_unalloc_region: unregister_chrdev_region(mbuf_dev, 1); out: @@ -452,6 +471,8 @@ static int __init mbuf_init(void) /* module unload */ static void __exit mbuf_exit(void) { + device_destroy( mbuf_class, mbuf_dev ); + class_destroy( mbuf_class ); /* remove the character deivce */ cdev_del(&mbuf_cdev); unregister_chrdev_region(mbuf_dev, 1); diff --git a/src/fe/gm_rcvr/Makefile b/src/fe/gm_rcvr/Makefile deleted file mode 100644 index 8c66b6994c29824ed85c5e69e097db8ec5818ce0..0000000000000000000000000000000000000000 --- a/src/fe/gm_rcvr/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# RTLinux makefile -include /opt/rtldk-2.2/rtlinuxpro/rtl.mk - - -TARGET_RTL := gm_rcvr.rtl -LIBRARY_OBJS := myri.o fb.o manage_network.o -LDFLAGS_$(TARGET_RTL) := -g $(LIBRARY_OBJS) - -$(TARGET_RTL): $(LIBRARY_OBJS) - -gm_rcvr.o: gm_rcvr.c - $(CC) $(CFLAGS) -c $< -o $@ -myri.o: ../myri.c - $(CC) $(CFLAGS) -D__KERNEL__ -c $< -fb.o: ../fb.c - $(CC) $(CFLAGS) -D__KERNEL__ -c $< -manage_network.o: manage_network.c - $(CC) $(CFLAGS) -D__KERNEL__ -c $< - -ALL += user_mmap $(TARGET_RTL) -CFLAGS += -I../../include -CFLAGS += -I/opt/gm/include -CFLAGS += -DSERVO2K -CFLAGS += -DSAS_CODE -CFLAGS += -D_ADVANCED_LIGO=1 -CFLAGS += -DUSE_GM=1 -CFLAGS += -g -#CFLAGS += -DNO_SYNC -#CFLAGS += -DNO_DAQ - -all: $(ALL) - -clean: - rm -f $(ALL) *.o - -include /opt/rtldk-2.2/rtlinuxpro/Rules.make - diff --git a/src/fe/gm_rcvr/gm_rcvr.c b/src/fe/gm_rcvr/gm_rcvr.c deleted file mode 100644 index d6f16a355c2380a1770ac236d59cf5109fa4d9ba..0000000000000000000000000000000000000000 --- a/src/fe/gm_rcvr/gm_rcvr.c +++ /dev/null @@ -1,64 +0,0 @@ -#include <rtl_time.h> -#include <time.h> -#include <fcntl.h> -#include <pthread.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdio.h> -#include <drv/myri.h> -#include <drv/gmnet.h> - -#define MMAP_SIZE 1024*1024*64-5000 - -extern void *manage_network(void *); -extern int stop_net_manager; - -unsigned char *_ipc_shm; - -int main(int argc, char **argv) -{ - int wfd; - char *file_name = "/rtl_mem_ipc"; - - wfd = shm_open(file_name, RTL_O_RDWR, 0666); - if (wfd == -1) { - printf("open r/w failed on %s (%d)\n", file_name, errno); - rtl_perror("shm_open()"); - return -1; - } - _ipc_shm = (unsigned char *)rtl_mmap(NULL,MMAP_SIZE,PROT_READ|PROT_WRITE,MAP_SHARED,wfd,0); - if (_ipc_shm == MAP_FAILED) { - printf("mmap failed for IPC shared memory area\n"); - rtl_perror("mmap()"); - return -1; - } - - /* Open Myrinet */ - if (myriNetInit(-1) != 1) return 1; - -#if 0 - /* Register IPC memory; Only first 4K are registered */ - gm_status_t status = gm_register_memory(netPort, _ipc_shm, GM_PAGE_LEN); - if (status != GM_SUCCESS) { - printk ("Couldn't register memory for DMA; error=%d", status); - return 0; - } -#endif - - - /* create the thread */ - rtl_pthread_t thread; - pthread_create(&thread, NULL, manage_network, 0); - - /* wait for us to be removed or killed */ - rtl_main_wait(); - stop_net_manager = 1; - rtl_pthread_cancel(thread); - rtl_pthread_join(thread, NULL); - - //gm_deregister_memory(netPort, _ipc_shm, GM_PAGE_LEN); - - myriNetClose(); - - return 0; -} diff --git a/src/fe/gm_rcvr/manage_network.c b/src/fe/gm_rcvr/manage_network.c deleted file mode 100644 index 4848c36c7b33cae424a0ac955c03717337f98447..0000000000000000000000000000000000000000 --- a/src/fe/gm_rcvr/manage_network.c +++ /dev/null @@ -1,114 +0,0 @@ -#include <linux/types.h> -#include <linux/pci.h> -#include <asm/io.h> -#include <asm/uaccess.h> -#include <drv/gmnet.h> -#include <drv/myri.h> -#include <rtl_time.h> - -int stop_net_manager = 0; -extern unsigned char *_ipc_shm; - -typedef struct -{ - int messages_expected; - int callbacks_pending; -} gm_s_e_context_t; - -gm_s_e_context_t context; - -static void -my_send_callback (struct gm_port *port, void *the_context, - gm_status_t the_status) -{ - /* One pending callback has been received */ - ((gm_s_e_context_t *)the_context)->callbacks_pending--; - - switch (the_status) - { - case GM_SUCCESS: - break; - - case GM_SEND_DROPPED: - printk ("**** Send dropped!\n"); - break; - - default: - printk ("Send completed with error %d", the_status); - } -} - - -void *manage_network(void *foo) -{ - gm_s_e_id_message_t *id_message; - - gm_u32_t my_node_id; - unsigned int my_global_id = 0; - gm_get_node_id (netPort, &my_node_id); - gm_status_t status = gm_node_id_to_global_id (netPort, my_node_id, &my_global_id); - if (status != GM_SUCCESS) { - printk ("Couldn't convert node ID to global ID; error=%d", status); - return 0; - } - - /* FIXME: Program appears to crash badly on a 4-way x86_64 system */ - /* Since I can't register shared memory, I can't use this program */ - /* Register IPC memory; Only first 4K are registered */ - status = gm_register_memory(netPort, _ipc_shm, GM_PAGE_LEN); - if (status != GM_SUCCESS) { - printk ("Couldn't register memory for DMA; error=%d", status); - return 0; - } - - /* Allocate message buffer */ - id_message = (gm_s_e_id_message_t *)gm_dma_calloc (netPort, 1, sizeof(gm_s_e_id_message_t)); - if (id_message == 0) { - printk ("Couldn't allocate output buffer for id_message\n"); - return 0; - } - - id_message->directed_recv_buffer_addr = gm_hton_u64((gm_size_t)_ipc_shm); - id_message->global_id = gm_hton_u32(my_global_id); - - /* Receive messages */ - for (;!stop_net_manager;) { - gm_recv_event_t *event = gm_receive (netPort); - switch (GM_RECV_EVENT_TYPE(event)) { - case GM_RECV_EVENT: - case GM_HIGH_RECV_EVENT: - { - daqMessage *rcvData = (daqMessage *)gm_ntohp(event->recv.buffer); - if (rcvData == 0) { - printk("Received zero pointer!\n"); - break; - } - if (strcmp(rcvData->message,"STT") == 0) { - gm_u32_t node_id = gm_ntoh_u16(event->recv.sender_node_id); - int dcuId = ntohl(rcvData->dcuId); - printk("Recv'd init from dcuId = %d GM node id %d\n", dcuId, node_id); - // Send back the id_message, which includes the DMA memory address info - gm_send_with_callback (netPort, - id_message, - GM_RCV_MESSAGE_SIZE, - sizeof(gm_s_e_id_message_t), - GM_DAQ_PRIORITY, - node_id, - GM_PORT_NUM_SEND, - my_send_callback, - &context); - context.callbacks_pending++; - } - } - case GM_NO_RECV_EVENT: - break; - default: - // This is where sent message callbacks go - gm_unknown (netPort, event); /* gm_unknown calls the callback */ - } - rtl_usleep(100000); - } - - gm_dma_free (netPort, id_message); - return 0; -} diff --git a/src/fe/rtai_shmem/GNUmakefile b/src/fe/rtai_shmem/GNUmakefile deleted file mode 100644 index 686a63db15ce2cf235775e157dff190482652379..0000000000000000000000000000000000000000 --- a/src/fe/rtai_shmem/GNUmakefile +++ /dev/null @@ -1,26 +0,0 @@ -# RTAI Makeflie - -prefix := $(shell rtai-config --prefix) - -ifeq ($(prefix),) -$(error Please add <rtai-install>/bin to your PATH variable) -endif - -ARCH = $(shell rtai-config --arch) -# If an arch-dependent dir is found, process it too. -ARCHDIR = $(shell test -d $(ARCH) && echo $(ARCH) || echo) - -CC = $(shell rtai-config --cc) - -LXRT_CFLAGS = $(shell rtai-config --lxrt-cflags) -LINUX_DIR = $(shell rtai-config --linux-dir) - - -all:: - $(MAKE) -C $(LINUX_DIR) CC=$(CC) SUBDIRS=$$PWD V=$(V) modules -# @if test -e $(LINUX_DIR)/Module.symvers; then mv -f $(LINUX_DIR)/Module.symvers $(LINUX_DIR)/__Module.symvers; fi; if test -e $(LINUX_DIR)/vmlinux; then mv -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/__vmlinux; fi; \ - $(MAKE) -C $(LINUX_DIR) CC=$(CC) SUBDIRS=$$PWD V=$(V) modules \ - && if test -e $(LINUX_DIR)/__Module.symvers; then mv -f $(LINUX_DIR)/__Module.symvers $(LINUX_DIR)/Module.symvers; fi && if test -e $(LINUX_DIR)/__vmlinux; then mv -f $(LINUX_DIR)/__vmlinux $(LINUX_DIR)/vmlinux; fi - -clean:: - $(RM) $(LINUX_DIR)/.tmp_versions/*_rt.mod *.o *.ko *.mod.c .*.cmd diff --git a/src/fe/rtai_shmem/Makefile b/src/fe/rtai_shmem/Makefile deleted file mode 100644 index 2d3a98b454f5b21ef716823887115b9a2b5c268a..0000000000000000000000000000000000000000 --- a/src/fe/rtai_shmem/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# Real Time Application Interface - -LDFLAGS_$(TARGET_RTL) := -g $(LIBRARY_OBJS) - -$(TARGET_RTL): $(LIBRARY_OBJS) - -setup_shmem.o: setup_shmem.c - $(CC) $(CFLAGS) -c $< -o $@ - -EXTRA_CFLAGS += -DRTAI=1 -EXTRA_CFLAGS += -I$(SUBDIRS)/../../include -#EXTRA_CFLAGS += -I/opt/gm/include -EXTRA_CFLAGS += -DSERVO32K -EXTRA_CFLAGS += -DOMC_CODE -EXTRA_CFLAGS += -D_ADVANCED_LIGO=1 -EXTRA_CFLAGS += -g -#Comment out to enable 1PPS synchronization -EXTRA_CFLAGS += -DNO_SYNC -#Uncomment to disable DAQ and testpoints -EXTRA_CFLAGS += -DNO_DAQ -#Uncomment to enable local frame builder; comment out USE_GM setting too -EXTRA_CFLAGS += -DSHMEM_DAQ -#EXTRA_CFLAGS += -DUSE_GM=1 -#Comment out to stop A/D oversampling -EXTRA_CFLAGS += -DOVERSAMPLE -#Comment out to stop interpolating D/A outputs -EXTRA_CFLAGS += -DOVERSAMPLE_DAC -#Comment out to disable initial LIGO compatibility -EXTRA_CFLAGS += -DCOMPAT_INITIAL_LIGO -#Uncomment to run on a specific CPU -#EXTRA_CFLAGS += -DSPECIFIC_CPU=2 - -EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -I/usr/include -ffast-math - -obj-m += setup_shmem.o - -#setup_shmem-objs := setup_shmem.o diff --git a/src/fe/rtai_shmem/run b/src/fe/rtai_shmem/run deleted file mode 100755 index b263fb483c18d63180958230a4b67e8bb22adf06..0000000000000000000000000000000000000000 --- a/src/fe/rtai_shmem/run +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -if [ $UID != 0 ]; then SUDO="sudo "; else SUDO=""; fi -echo -echo "*** Simple RTAI SHM demo (kernel) ***" -echo "Press <enter> to load modules:" -read junk -cd ..; sudo ./ldmod; cd - -echo -echo "Now start the realtime process <enter>, <ctrl-C> to end it." -read junk -sync -sudo /sbin/insmod ./setup_shmem.ko; -#./display -echo -echo "Done. Press <enter> to remove the modules." -read junk -./rem diff --git a/src/fe/rtai_shmem/setup_shmem.c b/src/fe/rtai_shmem/setup_shmem.c deleted file mode 100644 index 6c7ec82e60a13acd2b402e895dd6e20074d63b8b..0000000000000000000000000000000000000000 --- a/src/fe/rtai_shmem/setup_shmem.c +++ /dev/null @@ -1,32 +0,0 @@ -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/slab.h> -#include <rtai.h> -#include <rtai_sched.h> -#include <rtai_shm.h> -#include <rtai_nam2num.h> - -MODULE_DESCRIPTION("Create OM1 shared memory"); -MODULE_AUTHOR("Alex Ivanov<aivanov@ligo.caltech.edu>"); -MODULE_LICENSE("GPL"); - -static char *sysname = "om1"; -static char *sysname_daq = "om1_daq"; -#define MMAP_SIZE 1024*1024*64 - -int init_module() { - // Allocate FE to Epics comm area - void *addr = rtai_kmalloc(nam2num(sysname), MMAP_SIZE); - printk("nam2num(%s)=%d; returned addr = 0x%x\n", sysname, nam2num(sysname), addr); - // Allocate FE DAQ area - addr = rtai_kmalloc(nam2num(sysname_daq), MMAP_SIZE); - printk("nam2num(%s)=%d; returned addr = 0x%x\n", sysname_daq, nam2num(sysname), addr); - // Allocate IPC area - rtai_kmalloc(nam2num("ipc"), MMAP_SIZE); - return 0; -} -void cleanup_module (void) { - rtai_kfree(nam2num(sysname)); - rtai_kfree(nam2num(sysname_daq)); - rtai_kfree(nam2num("ipc")); -} diff --git a/src/fe/shmem/Makefile b/src/fe/shmem/Makefile deleted file mode 100644 index 11d97cc44999c569b56d1270d6e84062adf60ba7..0000000000000000000000000000000000000000 --- a/src/fe/shmem/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# RTLinux makefile -include /opt/rtldk-2.2/rtlinuxpro/rtl.mk -#include /home/controls/common_pc_64_build/build/rtcore-base-5.1/rtl.mk - - -TARGET_RTL := setup_shmem.rtl -LIBRARY_OBJS := map.o - -ALL += setup_shmem.rtl -CFLAGS += -I../../include -DRTL_BUILD - -all: $(ALL) - -clean: - rm -f $(ALL) *.o - -include /opt/rtldk-2.2/rtlinuxpro/Rules.make -#include /home/controls/common_pc_64_build/build/rtcore-base-5.1/Rules.make - diff --git a/src/fe/shmem/setup_shmem.c b/src/fe/shmem/setup_shmem.c deleted file mode 100644 index 3f7fcc0195bf3d45f4be08b249799fbb758b6134..0000000000000000000000000000000000000000 --- a/src/fe/shmem/setup_shmem.c +++ /dev/null @@ -1,104 +0,0 @@ -#include <time.h> -#include <fcntl.h> -#include <pthread.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdio.h> - -#define MMAP_SIZE 1024*1024*64-5000 - - -/* How many systems configured */ -int sys_count = 0; - -/* Systems information (configuration) */ -struct sys_info{ - char name[128]; /* System name */ - int adcs; /* ADC boards count */ - int dacs; /* DAC board count */ -} sys_info[128]; - -char * -get_fname(int s) { - static char fname[128] = "/rtl_epics"; - switch (sys_count) { - case 0: - break; - default: - sprintf(fname, "/rtl_mem_%s", sys_info[s].name); - break; - } - return fname; -} - -/* ./setup_shmem.rtl 'das,adc=1,dac=1' 'pde,adc=1,dac=1' */ - -int main(int argc, char **argv) -{ - int cnt, i; - sys_count = 0; - memset(sys_info, 0, sizeof(sys_info)); - - if (argc > 1) { - for (i = 0; i < argc-1; i++) { - strcpy(sys_info[i].name, argv[i+1]); - sys_info[i].adcs = 1; - sys_info[i].dacs = 0; - sys_info[argc-1+i] = sys_info[i]; - strcat(sys_info[argc-1+i].name, "_daq"); - } - sys_count = argc - 1; - sys_count *= 2; - } - /* Add IPC area */ - strcpy(sys_info[sys_count].name, "ipc"); - sys_info[sys_count].adcs = 1; - sys_info[sys_count].dacs = 0; - sys_count += 1; -#if 0 - for (i = 0; i < sys_count; i++) { - printf("%s: adcs=%d, dacs=%d\n", sys_info[i].name, sys_info[i].adcs, sys_info[i].dacs); - } -#endif - - cnt = sys_count; - if (cnt == 0) cnt = 1; - -#if defined(RTL_BUILD) - for (i = 0; i < cnt; i++) { - int wfd; - /* - * Create the shared memory area. By passing a non-zero value - * for the mode, this means we also create a node in the GPOS. - */ - char *file_name = get_fname(i); - wfd = shm_open(file_name, RTL_O_CREAT, 0666); - if (wfd == -1) { - printf("open failed for write on %s (%d)\n", file_name, errno); - rtl_perror("shm_open()"); - return -1; - } - - /* Set the shared area to the right size */ - if (0 != ftruncate(wfd,MMAP_SIZE)) { - printf("ftruncate failed (%d)\n",errno); - rtl_perror("ftruncate()"); - return -1; - } - - close(wfd); - } - - /* wait for us to be removed or killed */ - rtl_main_wait(); - - /* Note that this is a shared area created with shm_open() - we close - * it with close(), but use shm_unlink() to actually destroy the area - */ - for (i = 0; i < cnt; i++) { - shm_unlink(get_fname(i)); - } -#endif - - return 0; -} diff --git a/src/fe/test/gm_direct.c b/src/fe/test/gm_direct.c deleted file mode 100644 index 4454088701ec09453ea02fdb6e235fe3c517a1e2..0000000000000000000000000000000000000000 --- a/src/fe/test/gm_direct.c +++ /dev/null @@ -1,343 +0,0 @@ -/* test gm_direct_send() latency */ -#include <stdio.h> -#include <rtl_time.h> -#include <fcntl.h> -#include <pthread.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "msr.h" - -#include <drv/gmnet.h> - -/* gm receiver host name */ -char receiver_nodename[64]; - -/* if we are running in slave mode */ -int slave = 0; - -#define CPU_RATE 2800 - -int test_size = 32; -struct gm_port *netPort = 0; -volatile void *netInBuffer = 0; -volatile void *netDmaInBuffer = 0; -volatile void *netDmaOutBuffer = 0; -static void *netOutBuffer = 0; -gm_status_t status; -gm_u32_t receiver_node_id; -gm_s_e_id_message_t *id_message = 0; -unsigned int my_global_id = 0; -gm_u32_t my_node_id; -gm_u32_t receiver_global_id; -gm_remote_ptr_t directed_send_addr; - -void -cleanup() { - if (netPort) { - if (netDmaInBuffer) { - gm_dma_free (netPort, netDmaInBuffer); - } - if (netDmaOutBuffer) { - gm_dma_free (netPort, netDmaOutBuffer); - } - if (netInBuffer) { - gm_dma_free (netPort, netInBuffer); - } - if (netOutBuffer) { - gm_dma_free (netPort, netOutBuffer); - } - if (id_message) { - gm_dma_free (netPort, id_message); - } - gm_close (netPort); - gm_finalize(); - } - //gm_exit (status); -} - - -typedef struct -{ - int messages_expected; - int callbacks_pending; -} gm_s_e_context_t; - -gm_s_e_context_t context; -int send_complete = 0; - -/* This function is called inside gm_unknown() when there is a callback - ready to be processed. It tells us that a send has completed, either - successfully or with error. */ -static void -my_send_callback (struct gm_port *port, void *the_context, - gm_status_t the_status) -{ - /* One pending callback has been received */ - ((gm_s_e_context_t *)the_context)->callbacks_pending--; - - switch (the_status) - { - case GM_SUCCESS: - send_complete = 1; - printf ("**** Send complete!\n"); - break; - - case GM_SEND_DROPPED: - printf ("**** Send dropped!\n"); - break; - - default: - gm_perror ("Send completed with error", the_status); - } -} - -/* Transmit init message to slave */ -void -send_init_message(gm_u32_t nid) { - unsigned long send_length; - daqMessage *daqSendMessage; - daqSendMessage = (daqMessage *)netOutBuffer; - sprintf (daqSendMessage->message, "STT"); - send_length = (unsigned long) sizeof(*daqSendMessage); - send_complete = 0; - gm_send_with_callback (netPort, - netOutBuffer, - GM_RCV_MESSAGE_SIZE, - send_length, - GM_DAQ_PRIORITY, - nid, - 2, - my_send_callback, - &context); - context.callbacks_pending++; - for(;send_complete;); -} - - -gm_u32_t -recv_init_message() { - int i; - gm_recv_event_t *event; - daqMessage *rcvData; - gm_u32_t node_id = 0; - gm_s_e_id_message_t *id_message; - -for ( i = 0; i < 100; i++) { - /* Slave receives init message from master */ - event = gm_blocking_receive (netPort); - switch (GM_RECV_EVENT_TYPE(event)) { - case GM_RECV_EVENT: - case GM_HIGH_RECV_EVENT: - case GM_PEER_RECV_EVENT: - case GM_FAST_PEER_RECV_EVENT: - rcvData = (daqMessage *)gm_ntohp(event->recv.buffer); - if (rcvData == 0) { - printf("received zero pointer\n"); - break; - } - - if (gm_ntoh_u32 (event->recv.length) - == sizeof (gm_s_e_id_message_t)) { - id_message = gm_ntohp (event->recv.message); - receiver_global_id = gm_ntoh_u32(id_message->global_id); - directed_send_addr = - gm_ntoh_u64(id_message->directed_recv_buffer_addr); - printf("received remote buffer pointer\n"); - } else - - // Received startup message - // All clients must send this message on startup - if (strcmp(rcvData->message,"STT") == 0) { - node_id = gm_ntoh_u16(event->recv.sender_node_id); - printf("Recv'd init from node %d\n", node_id); - gm_send_with_callback (netPort, - id_message, - GM_RCV_MESSAGE_SIZE, - sizeof(*id_message), - GM_DAQ_PRIORITY, - node_id, - 2, - my_send_callback, - &context); - context.callbacks_pending++; - } else { - printf("invalid message received\n"); - } - gm_provide_receive_buffer (netPort, netInBuffer, GM_RCV_MESSAGE_SIZE, - GM_DAQ_PRIORITY); - return node_id; - break; - case GM_NO_RECV_EVENT: - break; - - default: - gm_unknown (netPort, event); - break; - } -} -return 0; -} - -inline void wait_for_test_data() { - for (;((int *)netInBuffer) [test_size-1] == 0;); -} - -inline void -send_test_data(gm_u32_t nid) { - int i; - for (i = 0 ; i < test_size; i++) - ((int *)netDmaOutBuffer)[i] = 1; - - send_complete = 0; - gm_directed_send_with_callback (netPort, - netDmaOutBuffer, - (gm_remote_ptr_t)directed_send_addr, - (unsigned long) sizeof(int) * test_size, - GM_DAQ_PRIORITY, - nid, - 2, - my_send_callback, - &context); - context.callbacks_pending++; - for(;send_complete;); -} - -int -main(int argc, char *argv[]) -{ - int i; - pthread_attr_t attr; - rtl_pthread_t wthread; - void *fe_start(void *); - - if (argc != 2) { - printf ("Usage: %s --slave | %s <receive node name>\n", - argv[0], argv[0]); - return 1; - } - if (!strcmp(argv[1], "--slave")) slave = 1; - else strcpy(receiver_nodename, argv[1]); - - // Initialize interface - gm_init(); - - status = gm_open (&netPort, 0 /* board */, 2 /*port */, "blah", - (enum gm_api_version) GM_API_VERSION_1_1); - if (status != GM_SUCCESS) { - gm_perror ("Couldn't open GM port", status); - cleanup(); - return 1; - } - - netDmaInBuffer = gm_dma_calloc (netPort, GM_RCV_BUFFER_COUNT, - GM_RCV_BUFFER_LENGTH); - if (netDmaInBuffer == 0) { - printf ("Couldn't allocate netDmaInBuffer\n"); - cleanup(); - return 1; - } - - netDmaOutBuffer = gm_dma_calloc (netPort, GM_RCV_BUFFER_COUNT, - GM_RCV_BUFFER_LENGTH); - if (netDmaOutBuffer == 0) { - printf ("Couldn't allocate netDmaOutBuffer\n"); - cleanup(); - return 1; - } - - netInBuffer = gm_dma_calloc (netPort, GM_RCV_BUFFER_COUNT, - GM_RCV_BUFFER_LENGTH); - if (netInBuffer == 0) { - printf ("Couldn't allocate netInBuffer\n"); - cleanup(); - return 1; - } - gm_provide_receive_buffer (netPort, netInBuffer, GM_RCV_MESSAGE_SIZE, - GM_DAQ_PRIORITY); - - netOutBuffer = gm_dma_calloc (netPort, GM_RCV_BUFFER_COUNT, - GM_RCV_BUFFER_LENGTH); - if (netOutBuffer == 0) { - printf("Couldn't allocate out_buffer\n"); - cleanup(); - return 1; - } - - id_message = (gm_s_e_id_message_t *)gm_dma_calloc (netPort, 1, - sizeof(*id_message)); - if (id_message == 0) { - printf ("Couldn't allocate output buffer for id_message\n"); - cleanup(); - return 1; - } - - gm_get_node_id (netPort, &my_node_id); - status = gm_node_id_to_global_id (netPort, my_node_id, &my_global_id); - if (status != GM_SUCCESS) { - gm_perror ("Couldn't convert node ID to global ID", status); - cleanup(); - return 1; - } - - id_message->directed_recv_buffer_addr = - gm_hton_u64((gm_size_t)netDmaInBuffer); - id_message->global_id = gm_hton_u32(my_global_id); - - gm_allow_remote_memory_access (netPort); - -#if 0 - rtl_pthread_attr_init(&attr); - rtl_pthread_attr_setcpu_np(&attr, 1); - /* mark this CPU as reserved - only RTLinux runs on it */ rtl_pthread_attr_setreserve_np(&attr, 1); - rtl_pthread_create(&wthread, &attr, fe_start, 0); -#endif - fe_start(0); - - //rtl_main_wait(); -} - -void* -fe_start(void *args) { - int i; - if (!slave) { - unsigned long cpuClock[2]; - status = gm_host_name_to_node_id_ex (netPort, 10000000, - receiver_nodename, - &receiver_node_id); - if (status == GM_SUCCESS) - printf ("receiver node ID is %d\n", receiver_node_id); - else { - printf ("Conversion of nodename %s to node id failed\n", - receiver_nodename); - gm_perror ("", status); - cleanup(); - return 1; - } - rdtscl(cpuClock[0]); - send_init_message(receiver_node_id); - gm_u32_t node_id = recv_init_message(); - rdtscl(cpuClock[1]); - printf("roundtrip time is %d\n", (cpuClock[1] - cpuClock[0])/CPU_RATE); - for (i = 0; i < test_size; i++) - ((int *)netDmaInBuffer) [i] = 0; - - recv_init_message(); /* receive remote buffer pointer */ - //send_test_data(node_id); - //wait_for_test_data(); - usleep(1000000); - printf("data %d\n", *((volatile int *)netDmaInBuffer)); - } else { - gm_u32_t node_id = recv_init_message(); - send_init_message(node_id); - recv_init_message(); /* receive remote buffer pointer */ -// for (i = 0; i < test_size; i++) -// ((int *)netDmaInBuffer) [i] = 0; - //wait_for_test_data(); - send_test_data(node_id); - } - cleanup(); - return -1; -} diff --git a/src/fe/test/gm_simple_example.h b/src/fe/test/gm_simple_example.h deleted file mode 100644 index 2905d8c887d095521f905939a0f46682fbc0443c..0000000000000000000000000000000000000000 --- a/src/fe/test/gm_simple_example.h +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************-*-c-*- - * Myricom GM networking software and documentation * - * Copyright (c) 1999-2003 by Myricom, Inc. * - * All rights reserved. See the file `COPYING' for copyright notice. * - *************************************************************************/ - -/** - @file gm_simple_example.h - - Include file for gm_simple_example_send.c and gm_simple_example_recv.c. -*/ - -#include "gm.h" - -/* The following define allows the programmer to turn GM strong typeing off - * regardless of the setting in gm.h. Note that if this effectively changes - * the definition in gm.h, the compiler will probably issue a warning, which - * may safely be ignored. - * - * It is *not* recommended to override GM_STRONG_TYPES to 1; see the definition - * in gm.h for the reasons. - */ -#if 0 -#define GM_STRONG_TYPES 0 -#endif - -#define GM_SIMPLE_EXAMPLE_PORT_NUM_RECV 4 -#define GM_SIMPLE_EXAMPLE_PORT_NUM_SEND 2 - -#define GM_SIMPLE_EXAMPLE_PRIORITY GM_LOW_PRIORITY - -#define GM_SIMPLE_EXAMPLE_SIZE 7 -#define GM_SIMPLE_EXAMPLE_BUFFER_COUNT 1 -#define GM_SIMPLE_EXAMPLE_BUFFER_LENGTH \ - (gm_max_length_for_size(GM_SIMPLE_EXAMPLE_SIZE)) - - -typedef struct /* Receiver-to-sender ID message */ -{ - gm_u64_n_t directed_recv_buffer_addr; /* UVA of directed-receive buffer */ - gm_u32_n_t global_id; /* Receiver's GM global ID */ - gm_u32_n_t slack; /* Make length a multiple of 64 */ -} gm_s_e_id_message_t; diff --git a/src/fe/test/gm_simple_example_recv.c b/src/fe/test/gm_simple_example_recv.c deleted file mode 100644 index 069076c3ee7e88cf7dc48776c26bf0376bdcc899..0000000000000000000000000000000000000000 --- a/src/fe/test/gm_simple_example_recv.c +++ /dev/null @@ -1,317 +0,0 @@ -/************************************************************************* - * Myricom GM networking software and documentation * - * Copyright (c) 2001-2003 by Myricom, Inc. * - * All rights reserved. See the file `COPYING' for copyright notice. * - * * - * Portions Copyright 1999 by Cam Macdonnell - University of Alberta. * - * Used with permission. * - *************************************************************************/ - -/** - @file gm_simple_example_recv.c - - * Simple Send/Recv for GM - * Author: Max Stern (Myricom) - * Based on a program by Cam Macdonell - University of Alberta - * - * Syntax: gm_simple_example_recv <sender_nodename> [<local_board_num>] - * - * <sender_nodename> is required. Include the board_num suffix if the - * sender is using a board_num other than 0; e.g., hosta:1 for board 1 - * on host "hosta". - * - * The default for <local_board_num> is 0. - * - * Description: - * - * This program, together with gm_simple_example_send, serves as a super- - * simple example of sending and receiving in GM, using both the basic send - * (gm_send type) and the directed send (gm_directed_send type) paradigms. - * - * The programs are written to be portable and interoperable without - * respect to the pointer size or the "endianness" of the host platforms. - * - * This program, the "receiver" or slave process, takes the following main - * actions (see commentary in the code below for the "how" details): - * - * - uses gm_send_with_callback() to transmit its global id and its - * directed-receive buffer address to the "sender" process (which may be - * on the same or a different host); - * - * - loops on gm_receive() until both the send callback from the above send - * and an incoming message from gm_simple_example_send have been received - * (the incoming message serves as notification that the directed-receive - * buffer has been modified); - * - * - displays the contents of its directed-receive buffer, showing the - * contents stored there by gm_simple_example_send; - * - * - exits. - * - * See also the Description and the Usage Note in gm_simple_example_send.c. - * - * */ - -#include <stdlib.h> -#include <stdio.h> -#include "gm.h" -#include "gm_simple_example.h" - -/** A structure used to store the state of this simple example program. */ - -typedef struct -{ - int messages_expected; - int callbacks_pending; -} gm_s_e_context_t; - -static void wait_for_events (struct gm_port *p, - gm_s_e_context_t *the_context); -static void my_send_callback (struct gm_port *port, - void *the_context, - gm_status_t the_status); - - -int -main (int argc, char **argv) -{ - struct gm_port *my_port; - char sender_nodename[64]; - gm_s_e_context_t context; - gm_status_t main_status; - int my_board_num = 0; /* Default board_num is 0 */ - gm_u32_t my_node_id, sender_node_id; - unsigned int my_global_id = 0; - void *directed_receive_buffer; - void *in_buffer; - gm_s_e_id_message_t *id_message; - gm_size_t alloc_length; - - context.messages_expected = 0; - context.callbacks_pending = 0; - - gm_init(); - - /* Parse the program argument(s) */ - - if ((argc < 2) || (argc > 3)) - { - printf ("USAGE: gm_simple_example_recv <sender_nodename> " - "[<local_board_num>]\n"); - main_status = GM_INVALID_PARAMETER; - goto abort_with_nothing; - } - if (gm_strlen (argv[1]) + 1 > sizeof (sender_nodename)) - { - printf ("[recv] *** ERROR: " - "sender nodename length %ld exceeds maximum of %ld\n", - gm_strlen (argv[1]), sizeof (sender_nodename) - 1); - main_status = GM_INVALID_PARAMETER; - goto abort_with_nothing; - } - gm_strncpy (sender_nodename, /* Mandatory 1st parameter */ - argv[1], - sizeof (sender_nodename) - 1); - if (argc > 2) - { - my_board_num = atoi (argv[2]); /* Optional 2nd parameter */ - } - - /* Open a port on our local interface. */ - - main_status = gm_open (&my_port, my_board_num, - GM_SIMPLE_EXAMPLE_PORT_NUM_RECV, - "gm_simple_example_recv", - (enum gm_api_version) GM_API_VERSION_1_1); - if (main_status == GM_SUCCESS) - { - printf ("[recv] Opened board %d port %d\n", - my_board_num, GM_SIMPLE_EXAMPLE_PORT_NUM_RECV); - } - else - { - gm_perror ("[recv] Couldn't open GM port", main_status); - goto abort_with_nothing; - } - - gm_get_node_id (my_port, &my_node_id); - main_status = gm_node_id_to_global_id (my_port, my_node_id, &my_global_id); - if (main_status != GM_SUCCESS) - { - gm_perror ("[recv] Couldn't convert node ID to global ID", main_status); - goto abort_with_open_port; - } - - /* Try to convert the sender's hostname into a node ID. */ - - main_status = gm_host_name_to_node_id_ex - (my_port, 10000000, sender_nodename, &sender_node_id); - if (main_status == GM_SUCCESS) - { - printf ("[recv] sender node ID is %d\n", sender_node_id); - } - else - { - printf ("[recv] Conversion of nodename %s to node id failed\n", - sender_nodename); - gm_perror ("[recv]", main_status); - goto abort_with_open_port; - } - if (my_node_id == sender_node_id) - { - printf ("[recv] NOTE: sender and receiver are same node, id=%d\n", - my_node_id); - } - - /* Allocate DMAable message buffers. */ - - alloc_length = sizeof(*id_message); - id_message = (gm_s_e_id_message_t *)gm_dma_calloc (my_port, 1, alloc_length); - if (id_message == 0) - { - printf ("[recv] Couldn't allocate output buffer for id_message\n"); - main_status = GM_OUT_OF_MEMORY; - goto abort_with_open_port; - } - - in_buffer = gm_dma_calloc (my_port, GM_SIMPLE_EXAMPLE_BUFFER_COUNT, - GM_SIMPLE_EXAMPLE_BUFFER_LENGTH); - if (in_buffer == 0) - { - printf ("[recv] Couldn't allocate in_buffer\n"); - main_status = GM_OUT_OF_MEMORY; - goto abort_with_id_message; - } - - directed_receive_buffer = gm_dma_calloc (my_port, - GM_SIMPLE_EXAMPLE_BUFFER_COUNT, - GM_SIMPLE_EXAMPLE_BUFFER_LENGTH); - if (directed_receive_buffer == 0) - { - printf ("[recv] Couldn't allocate directed_receive_buffer\n"); - main_status = GM_OUT_OF_MEMORY; - goto abort_with_in_buffer; - } - - /* Allow any GM process to modify any of the local DMAable buffers. */ - - gm_allow_remote_memory_access (my_port); - - /* Compose and send the message to tell sender our node_id and our - directed-receive-buffer address */ - - /* Here we take advantage of the fact that gm_remote_ptr_t is 64 bits for - all platforms and architectures. */ - id_message->directed_recv_buffer_addr = - gm_hton_u64((gm_size_t)directed_receive_buffer); - id_message->global_id = gm_hton_u32(my_global_id); - - /* If, through a programming error, we had defined things such that - sizeof(*id_message) > gm_max_length_for_size(GM_SIMPLE_EXAMPLE_SIZE), - the following GM API call would return an error at run time. */ - gm_send_with_callback (my_port, - id_message, - GM_SIMPLE_EXAMPLE_SIZE, - sizeof(*id_message), - GM_SIMPLE_EXAMPLE_PRIORITY, - sender_node_id, - GM_SIMPLE_EXAMPLE_PORT_NUM_SEND, - my_send_callback, - &context); - context.callbacks_pending++; - - gm_provide_receive_buffer (my_port, in_buffer, GM_SIMPLE_EXAMPLE_SIZE, - GM_SIMPLE_EXAMPLE_PRIORITY); - - /* Prefill the directed-receive buffer with error message; - we should see it change. If not, an error has occurred. */ - sprintf ((char *)directed_receive_buffer, "*** AN ERROR HAS OCCURRED!"); - - context.messages_expected = 1; /* Now, we do expect a message from sender */ - - /* Nothing more to do but wait for callbacks and the incoming messages */ - - wait_for_events (my_port, &context); - - printf ("[recv] " - "Having received the incoming message from the sender, the\n" - " directed-receive buffer contains \"%s\"\n", - directed_receive_buffer); - - printf ("[recv] gm_simple_example_recv completed successfully\n"); - - gm_dma_free (my_port, directed_receive_buffer); - main_status = GM_SUCCESS; - - abort_with_in_buffer: - gm_dma_free (my_port, in_buffer); - abort_with_id_message: - gm_dma_free (my_port, id_message); - abort_with_open_port: - gm_close (my_port); - abort_with_nothing: - gm_finalize(); - gm_exit (main_status); -} - -static void -wait_for_events (struct gm_port *my_port, gm_s_e_context_t *the_context) -{ - gm_recv_event_t *event; - void *buffer; - unsigned int size; - - - while ((the_context->callbacks_pending > 0) - || (the_context->messages_expected > 0)) - { - event = gm_receive (my_port); - - switch (GM_RECV_EVENT_TYPE(event)) - { - case GM_RECV_EVENT: - case GM_PEER_RECV_EVENT: - case GM_FAST_PEER_RECV_EVENT: - printf ("[recv] Received incoming message: \"%s\"\n", - (char *) gm_ntohp (event->recv.message)); - the_context->messages_expected--; - /* Return the buffer for reuse */ - buffer = gm_ntohp (event->recv.buffer); - size = (unsigned int)gm_ntoh_u8 (event->recv.size); - gm_provide_receive_buffer (my_port, buffer, size, - GM_SIMPLE_EXAMPLE_PRIORITY); - break; - - case GM_NO_RECV_EVENT: - break; - - default: - gm_unknown (my_port, event); /* gm_unknown calls the callback */ - } - } -} - -/* This function is called inside gm_unknown() when there is a callback - ready to be processed. It tells us that a send has completed, either - successfully or with error. */ - -static void -my_send_callback (struct gm_port *port, void *the_context, - gm_status_t the_status) -{ - /* One pending callback has been received */ - ((gm_s_e_context_t *)the_context)->callbacks_pending--; - - switch (the_status) - { - case GM_SUCCESS: - break; - - case GM_SEND_DROPPED: - printf ("**** Send dropped!\n"); - break; - - default: - gm_perror ("Send completed with error", the_status); - } -} diff --git a/src/fe/test/gm_simple_example_send.c b/src/fe/test/gm_simple_example_send.c deleted file mode 100644 index 97fbbd4825279ad12499162692b1a8b5cf7cc68b..0000000000000000000000000000000000000000 --- a/src/fe/test/gm_simple_example_send.c +++ /dev/null @@ -1,320 +0,0 @@ -/************************************************************************* - * Myricom GM networking software and documentation * - * Copyright (c) 2001-2003 by Myricom, Inc. * - * All rights reserved. See the file `COPYING' for copyright notice. * - * * - * Portions Copyright 1999 by Cam Macdonnell - University of Alberta. * - * Used with permission. * - *************************************************************************/ - -/** - @file gm_simple_example_send.c - - * Simple Send/Recv for GM - * Author: Max Stern (Myricom) - * Based on a program by Cam Macdonell - University of Alberta - * - * Syntax: gm_simple_example_send [<local_board_num>] - * - * The default for <local_board_num> is 0. - * - * Description: - * - * This program, together with gm_simple_example_recv, serves as a super- - * simple example of sending and receiving in GM, using both the basic send - * (gm_send type) and the directed send (gm_directed_send type) paradigms. - * - * The programs are written to be portable and interoperable without - * respect to the pointer size or the "endianness" of the host platforms. - * - * This program, the "sender" or master process, takes the following main - * actions (see commentary in the code below for the "how" details): - * - * - loops on gm_receive() until it receives a message. It assumes that - * this message (if the proper length) contains the receiver's global id - * and the receiver's directed-send buffer address; - * - * - uses gm_directed_send_with_callback() to copy a message directly into - * the receiver's memory (note: the receiver does not do a gm_receive()); - * - * - uses gm_send_with_callback() to transmit a normal message, which - * the receiver will get via gm_receive(); - * - * - loops on gm_receive() until both the send callbacks have been consumed; - * - * - exits. - * - * Usage Note: - * - * Assume the sender is to run on board 1 on hosta, and the receiver - * on board 0 on hostb. The commands would look like this: - * - * First, on hostb: - * hostb> gm_simple_example_recv hosta:1 - * - * Then, on hosta: - * hosta> gm_simple_example_send 1 - * - * Note: The sender and the receiver use different GM ports. This makes it - * possible, if desired, to run the sender and receiver over the same - * interface. The commands might look like this: - * - * First, on hosta: - * hosta> gm_simple_example_recv hosta & - * - * Then, also on hosta: - * hosta> gm_simple_example_send - * - * See also the Description in gm_simple_example_recv.c. - * - * */ - -#include <stdlib.h> -#include <stdio.h> -#include "gm.h" -#include "gm_simple_example.h" - -static void my_send_callback (struct gm_port *port, - void *the_context, - gm_status_t the_status); - - -int -main (int argc, char **argv) -{ - static struct gm_port *my_port = 0; - static void *out_buffer = 0, *in_buffer = 0, *directed_send_buffer = 0; - int my_board_num = 0; /* Default board_num is 0 */ - gm_u32_t receiver_node_id; - gm_u32_t receiver_global_id; - unsigned int send_length; - int expected_messages = 1; - gm_remote_ptr_t directed_send_addr; - gm_recv_event_t *event; - gm_status_t main_status; -/* expected_callbacks makes sure we don't exit until we have handled all - the callbacks we expect. */ - static int expected_callbacks = 0; - - gm_init(); - - /* Parse the program argument(s) */ - - if (argc > 2) - { - printf ("USAGE: gm_simple_example_send [<local_board_num>]\n"); - main_status = GM_INVALID_PARAMETER; - goto abort_with_nothing; - } - if (argc > 1) - { - my_board_num = atoi (argv[1]); /* Optional parameter */ - } - - /* Open a port on our local interface. */ - - main_status = gm_open (&my_port, my_board_num, - GM_SIMPLE_EXAMPLE_PORT_NUM_SEND, - "gm_simple_example_send", - (enum gm_api_version) GM_API_VERSION_1_1); - if (main_status == GM_SUCCESS) - { - printf ("[send] Opened board %d port %d\n", - my_board_num, GM_SIMPLE_EXAMPLE_PORT_NUM_SEND); - } - else - { - gm_perror ("[send] Couldn't open GM port", main_status); - goto abort_with_nothing; - } - - /* Allocate DMAable message buffers. */ - - out_buffer = gm_dma_calloc (my_port, GM_SIMPLE_EXAMPLE_BUFFER_COUNT, - GM_SIMPLE_EXAMPLE_BUFFER_LENGTH); - if (out_buffer == 0) - { - printf ("[send] Couldn't allocate out_buffer\n"); - main_status = GM_OUT_OF_MEMORY; - goto abort_with_open_port; - } - - in_buffer = gm_dma_calloc (my_port, GM_SIMPLE_EXAMPLE_BUFFER_COUNT, - GM_SIMPLE_EXAMPLE_BUFFER_LENGTH); - if (in_buffer == 0) - { - printf ("[send] Couldn't allocate in_buffer\n"); - main_status = GM_OUT_OF_MEMORY; - goto abort_with_out_buffer; - } - - directed_send_buffer = gm_dma_calloc (my_port, - GM_SIMPLE_EXAMPLE_BUFFER_COUNT, - GM_SIMPLE_EXAMPLE_BUFFER_LENGTH); - if (directed_send_buffer == 0) - { - printf ("[send] Couldn't allocate directed_send_buffer\n"); - main_status = GM_OUT_OF_MEMORY; - goto abort_with_in_buffer; - } - - /* Note that all send tokens are available */ - - /* Tell GM where our receive buffer is */ - - gm_provide_receive_buffer (my_port, in_buffer, GM_SIMPLE_EXAMPLE_SIZE, - GM_SIMPLE_EXAMPLE_PRIORITY); - - /* Wait for the message from gm_simple_example_recv */ - - while (expected_messages) - { - void *recv_buffer; - unsigned int size; - gm_s_e_id_message_t *id_message; - gm_u32_t recv_length; - - event = gm_receive (my_port); - recv_length = gm_ntoh_u32 (event->recv.length); - - switch (GM_RECV_EVENT_TYPE(event)) - { - case GM_RECV_EVENT: - case GM_PEER_RECV_EVENT: - case GM_FAST_PEER_RECV_EVENT: - if (recv_length != sizeof (gm_s_e_id_message_t)) - { - printf ("[send] *** ERROR: incoming message length %d " - "incorrect; should be %ld\n", - recv_length, sizeof (gm_s_e_id_message_t)); - main_status = GM_FAILURE; /* Unexpected incoming message */ - goto abort_with_directed_send_buffer; - } - - id_message = gm_ntohp (event->recv.message); - receiver_global_id = gm_ntoh_u32(id_message->global_id); - directed_send_addr = - gm_ntoh_u64(id_message->directed_recv_buffer_addr); - main_status = gm_global_id_to_node_id(my_port, - receiver_global_id, - &receiver_node_id); - if (main_status != GM_SUCCESS) - { - gm_perror ("[send] Couldn't convert global ID to node ID", - main_status); - goto abort_with_directed_send_buffer; - } - - expected_messages--; - - /* Return the buffer for reuse */ - - recv_buffer = gm_ntohp (event->recv.buffer); - size = (unsigned int)gm_ntoh_u8 (event->recv.size); - gm_provide_receive_buffer (my_port, recv_buffer, size, - GM_SIMPLE_EXAMPLE_PRIORITY); - break; - - case GM_NO_RECV_EVENT: - break; - - default: - gm_unknown (my_port, event); /* gm_unknown calls the callback */ - } - } /* while */ - - sprintf (directed_send_buffer, "Directed send was successful!"); - - /* Copy the buffer directly into the receiver's memory */ - - gm_directed_send_with_callback (my_port, - directed_send_buffer, - (gm_remote_ptr_t) directed_send_addr, - (unsigned long) - gm_strlen (directed_send_buffer) + 1, - GM_SIMPLE_EXAMPLE_PRIORITY, - receiver_node_id, - GM_SIMPLE_EXAMPLE_PORT_NUM_RECV, - my_send_callback, - &expected_callbacks); - expected_callbacks++; - - sprintf (out_buffer, "This is the sender!!"); - - /* Now send a regular message, which will signal the receiver to look at - its directed-send buffer */ - - send_length = (unsigned long) gm_strlen (out_buffer) + 1; - gm_send_with_callback (my_port, - out_buffer, - GM_SIMPLE_EXAMPLE_SIZE, - send_length, - GM_SIMPLE_EXAMPLE_PRIORITY, - receiver_node_id, - GM_SIMPLE_EXAMPLE_PORT_NUM_RECV, - my_send_callback, - &expected_callbacks); - expected_callbacks++; - - /* Now we wait for the callbacks for the sends we did above */ - while (expected_callbacks) - { - event = gm_receive (my_port); - - switch (GM_RECV_EVENT_TYPE(event)) - { - case GM_RECV_EVENT: - case GM_PEER_RECV_EVENT: - case GM_FAST_PEER_RECV_EVENT: - printf ("[send] Receive Event (UNEXPECTED)\n"); - main_status = GM_FAILURE; /* Unexpected incoming message */ - goto abort_with_directed_send_buffer; - - case GM_NO_RECV_EVENT: - break; - - default: - gm_unknown (my_port, event); /* gm_unknown calls the callback */ - } - } - - printf ("[send] gm_simple_example_send completed successfully\n"); - main_status = GM_SUCCESS; - - abort_with_directed_send_buffer: - gm_dma_free (my_port, directed_send_buffer); - abort_with_in_buffer: - gm_dma_free (my_port, in_buffer); - abort_with_out_buffer: - gm_dma_free (my_port, out_buffer); - abort_with_open_port: - gm_close (my_port); - abort_with_nothing: - gm_finalize(); - gm_exit (main_status); -} - -/* This function is called inside gm_unknown() when there is a callback - ready to be processed. It tells us that a send has completed, either - successfully or with error. */ - -static void -my_send_callback (struct gm_port *port, void *the_context, - gm_status_t the_status) -{ - /* One pending callback has been received */ - (*(int *)the_context)--; - - switch (the_status) - { - case GM_SUCCESS: - break; - - case GM_SEND_DROPPED: - printf ("**** Send dropped!\n"); - break; - - default: - gm_perror ("Send completed with error", the_status); - } -} diff --git a/src/gds/awgapi.c b/src/gds/awgapi.c index e12ee4f303e5c23dae0c0f1f590e9753e42db30b..1f21a2c47603464b4e5e42d45d9bdbc8683d1edc 100644 --- a/src/gds/awgapi.c +++ b/src/gds/awgapi.c @@ -104,11 +104,11 @@ static char *versionId = "Version $Id$" ; /* */ /*----------------------------------------------------------------------*/ #define _NETID "tcp" -#define _MAX_IFO 128 +#define _MAX_IFO 256 #define _MAX_AWG_PER_IFO 5 #define MAX_SLOT_NAME 256 #define MAX_SLOT_LIST 16 -#define _SHOWBUF_SIZE (128 * 1024) +#define _SHOWBUF_SIZE (256 * 1024) #if !defined (_AWG_LIB) && !defined (_CONFIG_DYNAMIC) #define PRM_FILE gdsPathFile ("/param", "awg.par") #define PRM_SECTION "awg" diff --git a/src/gds/rmorg.h b/src/gds/rmorg.h index 8edf418b676ab8bf059cf67772055749368042e3..b74c4696ee7f36e94339078864b464992a179545 100644 --- a/src/gds/rmorg.h +++ b/src/gds/rmorg.h @@ -127,7 +127,7 @@ extern "C" { @author DS, September 98 @see Testpoint Definition ************************************************************************/ -#define TP_MAX_NODE 128 +#define TP_MAX_NODE 256 /** Maximum number of test point interfaces. This number is currently 4 (LSC/ASC excitation and LSC/ASC test point readout). diff --git a/src/nds/main.cc b/src/nds/main.cc index cf7b8315de0c5d6d805d0d7cfcaa06b64e272b4d..d5511d543074e4c1bd4b843d46e9efb5dc5429b2 100644 --- a/src/nds/main.cc +++ b/src/nds/main.cc @@ -45,7 +45,7 @@ parse_args( int argc, char* argv[] ) const char* log_dest = nullptr; const char* run_dir = nullptr; - const char* default_run_dir = "/var/run/nds"; + const char* default_run_dir = "/run/nds"; auto arg_parser = args_create_parser( "The archive data retrieval service for daqd data" ); diff --git a/support/bin/rtcds.in b/support/bin/rtcds.in index 32a41cf04ea48e7c75aab0fcaf5239a02140d68e..143f608e6969620b57df6c08a51b7cb9b0bca541 100755 --- a/support/bin/rtcds.in +++ b/support/bin/rtcds.in @@ -109,8 +109,8 @@ list_host_sys() { check_host_sys() { for sys ; do - if ! systemctl is-enabled "$sys" ; then - log "System '$sys' is not enabled on this system (enable first)." + if ! systemctl is-enabled rts@${sys}.target ; then + log "System '$sys' is not enabled on this system, first enable with 'enable ${sys}'." exit 4 fi done diff --git a/support/etc/advligorts/daqd.standalone.sample.rc b/support/etc/advligorts/daqd.standalone.sample.rc index d3241ef880e6aaaf0aa6efd11a1e4dffeb50e776..12d2e9882b031fe7896853944a59456fa6ccb8a0 100644 --- a/support/etc/advligorts/daqd.standalone.sample.rc +++ b/support/etc/advligorts/daqd.standalone.sample.rc @@ -41,7 +41,7 @@ set minute-trend-frame-dir="/frames/trend/minute", "X-X5_M-", ".gwf"; #set raw-minute-trend-dir="/frames/trend/minute/raw"; #set raw_minute_trend_saving_period=5; -set nds-jobs-dir="/var/run/nds"; +set nds-jobs-dir="/run/nds"; set parameter "shmem_input" = "local_dc"; set parameter "shmem_size" = "104857600"; diff --git a/support/systemd/rts-nds.service b/support/systemd/rts-nds.service index 38f6db3205f0066d4a4d4f4a2154569462d6f92d..3de61b5215b3e27891526960301ce7894d5401a1 100644 --- a/support/systemd/rts-nds.service +++ b/support/systemd/rts-nds.service @@ -1,11 +1,11 @@ [Unit] -Description=Advanced LIGO RTS nds1 frame data retriever +Description=Advanced LIGO RTS NDS1 frame data retriever After=network-online.target [Service] +RuntimeDirectory=nds User=controls -Environment=LD_BIND_NOW=true -ExecStart=/usr/bin/nds /etc/advligorts/pipe +ExecStart=/usr/bin/nds --rundir /run/nds Restart=always [Install] diff --git a/support/systemd/rts@.target b/support/systemd/rts@.target index cbf211ee2ce4040b647f2d2dd6532adfd508d9b1..d30d9293ef8118c1fcf3f3228b265648dda944fe 100644 --- a/support/systemd/rts@.target +++ b/support/systemd/rts@.target @@ -1,5 +1,6 @@ [Unit] Description=Advanced LIGO RTS target: %i +After=remote-fs.target Requires=rts-epics@%i.service rts-module@%i.service rts-awgtpman@%i.service [Install] diff --git a/support/udev/gpstime.rules b/support/udev/gpstime.rules index 105db929b5b326b472475201959bc4109f867558..5c2f14fbee8c12cffc07213cc640abb161854281 100644 --- a/support/udev/gpstime.rules +++ b/support/udev/gpstime.rules @@ -1,3 +1 @@ -KERNEL=="gpstime", ACTION=="add", RUN+="__SHARE__/module-manage.sh add gpstime" -KERNEL=="gpstime", ACTION=="add", RUN+="__SHARE__/calc_gps_offset.py -a" -KERNEL=="gpstime", ACTION=="remove", RUN+="__SHARE__/module-manage.sh remove gpstime" +KERNEL=="gpstime", ACTION=="add", OWNER="advligorts", GROUP="advligorts", MODE="0664", RUN+="__SHARE__/calc_gps_offset.py -a" diff --git a/support/udev/mbuf.rules b/support/udev/mbuf.rules index 8b219fbf7fb2a58f6d802c0494fafe375702c1db..a504fb192212bc6aee11c55f0ad1ce8fd638aeff 100644 --- a/support/udev/mbuf.rules +++ b/support/udev/mbuf.rules @@ -1,2 +1 @@ -KERNEL=="mbuf", ACTION=="add", RUN+="__SHARE__/module-manage.sh add mbuf" -KERNEL=="mbuf", ACTION=="remove", RUN+="__SHARE__/module-manage.sh remove mbuf" +KERNEL=="mbuf", ACTION=="add", OWNER="advligorts", GROUP="advligorts", MODE="0660" diff --git a/support/udev/module-manage.sh b/support/udev/module-manage.sh deleted file mode 100755 index 984cbba8c7303563ad604af6f2b56fb583f1964a..0000000000000000000000000000000000000000 --- a/support/udev/module-manage.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -e - -function usage() { - local cmd=$(basename $0) - echo "usage: $cmd add|remove <module> -load/unload module, and create corresponding device node" >&2 - -} - -function error() { - echo "$@" >&2 - usage - exit 1 -} - -function check_module() { - local module="$1" - if [ -z "$module" ] ; then - error "must specify module" - fi -} - -function node_add() { - local module="$1" - check_module $module - modprobe $module - local dev=$(grep $module /proc/devices) - local major=${dev%% *} - mknod /dev/$module c $major 0 || true - chown controls /dev/$module -} - -function node_remove() { - local module="$1" - check_module $module - rm -f /dev/$module - rmmod $module 2>/dev/null || true -} - -########## - -cmd="$1" -module="$2" - -case $cmd in - add) - node_add "$module" - ;; - remove) - node_remove "$module" - ;; - help|-h|--help) - usage - ;; - *) - error "invalid command: $cmd" - ;; -esac