--- myrinet-322c.orig/include/myriApi.h Wed Jun 10 00:52:25 1998 +++ myrinet-322c/include/myriApi.h Fri Sep 10 15:37:55 1999 @@ -92,6 +92,9 @@ int myriApiSetInterruptMask (int unit, int channel,int mask); int myriApiSetMapLevel (int unit, int channel, unsigned short mapLevel); void myriApiLoadLanai(int unit, unsigned short sts, int mask, unsigned char *myriAddrPtr); +#if defined(LFC_IDLE_CODE) +void myriApiLoadLanai_idle(int unit); +#endif void myriApiInterruptEnable(int unit); void myriApiInterruptDisable(int unit); int myriApiInterruptPending(int unit); diff -Naur myrinet-322c.orig/make/intel_linux.VU myrinet-322c/make/intel_linux.VU --- myrinet-322c.orig/make/intel_linux.VU Thu Jan 1 01:00:00 1970 +++ myrinet-322c/make/intel_linux.VU Mon Sep 13 14:23:33 1999 @@ -0,0 +1,45 @@ +#intel_linux makefile definitions + +MAKE = /usr/bin/make + + +TCLLIB = -L/usr/lib -ltcl +TCLINC = -I/usr/include/tcl + +XSTUFF = /usr/X11R6 +X_INCLUDE = $(XSTUFF)/include +X_LIB = $(XSTUFF)/lib + +NETWORK_WIDGET_INCLUDE = /ufs/src/network-widget +XPM_INCLUDE = /ufs/src/xpm/lib + +MOTIF_LIBRARY = $(XSTUFF)/lib/libXm.a +MOTIF_RESOURCE_LIBRARY = $(XSTUFF)/lib/libMrm.a +X_UTILITY_LIBRARY = $(XSTUFF)/lib/libXmu.a +X_INTRINSICS_LIBRARY = $(XSTUFF)/lib/libXt.a +X_EXTENSIONS_LIBRARY = $(XSTUFF)/lib/libXext.a +X_LIBRARY = $(XSTUFF)/lib/libX11.a $(XSTUFF)/lib/libSM.a $(XSTUFF)/lib/libICE.a + +BFD_LIBRARY = $(MHOME)/lib/$(ARCH)/libbfd.a +BFD_INCLUDE = $(MHOME)/include +IBERTY_LIBRARY = $(MHOME)/lib/$(ARCH)/libiberty.a + +#LINUX = -L/usr/lib -b i486-linuxaout +LINUX = + +HOST_APPLICATION_COMPILER_FLAGS = $(LINUX) -g -O2 -Wall -DLANAI_ACCESS_EXPENSIVE +MOTIF_APPLICATION_COMPILER_FLAGS = $(LINUX) -g -O2 -Wall -DPC_UNIX +HOST_LIBRARY_COMPILER_FLAGS = $(LINUX) -g -O2 -Wall -static -DLANAI_ACCESS_EXPENSIVE + +HDF_INCLUDE = $(MHOME)/include/hdf +HDF_LIBRARY = $(MHOME)/lib/$(ARCH)/libdf.a + +# COMPILER = /usr/bin/gcc +COMPILER = gcc +# CPLUSPLUS_COMPILER = /usr/bin/gcc -x c++ +# -DSTDC_HEADERS headers hack to avoid failing on /usr/include/types.h +# in RedHat 5.2 +CPLUSPLUS_COMPILER = g++ -DSTDC_HEADERS + +AR = ar cru +RANLIB = ranlib diff -Naur myrinet-322c.orig/make/lanai.VU myrinet-322c/make/lanai.VU --- myrinet-322c.orig/make/lanai.VU Thu Jan 1 01:00:00 1970 +++ myrinet-322c/make/lanai.VU Mon Sep 13 14:24:06 1999 @@ -0,0 +1,34 @@ +LANAI2_TOOLS = /usr/local/myrinet/compiler/bin +#LANAI3_TOOLS= /ufs/lanai/tools/bin +LANAI3_TOOLS = /usr/local/VU/lanai3-2.8.1/bin +#LANAI3_GCC_TOOLS = /ufs/lanai/tools/bin +LANAI3_GCC_TOOLS = /usr/local/VU/lanai3-2.8.1/bin +#LANAI3_DASH_B = -B/ufs/lanai/tools/lib/gcc-lib/lanai3/2.7.2.1/ + +LANAI2_COMPILER = $(LANAI2_TOOLS)/cclan+2c -DMYRI_LANAI2 +LANAI2_LINKER = $(LANAI2_TOOLS)/ldlan+ +LANAI2_AR = ar cru +LANAI2_RANLIB = ranlib + +#should we add -msingle-context ??? didn't work with 2.7.2 J +# seemed to work with 2.7.2.1 A + +LANAI3_COMPILER = $(LANAI3_GCC_TOOLS)/lanai3-gcc $(LANAI3_DASH_B) \ + -m4.1 -msingle-context -O3 -x c++ \ + -DMYRI_LANAI4 -mno-partword-load-warning + +##turning off -O3 and -msingle-context because of DMA_CTR problems? +# +#LANAI3_COMPILER = $(LANAI3_GCC_TOOLS)/lanai3-gcc $(LANAI3_DASH_B) \ +# -O -x c++ \ +# -m4.1 -DMYRI_LANAI4 -mno-partword-load-warning + + +LANAI3_AS = $(LANAI3_GCC_TOOLS)/lanai3-gcc $(LANAI3_DASH_B) +LANAI3_LINKER = $(LANAI3_GCC_TOOLS)/lanai3-gcc $(LANAI3_DASH_B) +#LANAI3_GENDAT = /usr/local/myrinet/src/lanai/mcp/gendat +LANAI3_GENDAT = $(LANAI3_TOOLS)/gendat +LANAI3_RANLIB = $(LANAI3_TOOLS)/lanai3-ranlib +LANAI3_AR = $(LANAI3_TOOLS)/lanai3-ar cru + +LANAI_DEBUG_FLAGS = -DMYRI_ASSERT --- myrinet-322c.orig/src/PCIboard/myriInterface.c Thu Nov 19 00:22:35 1998 +++ myrinet-322c/src/PCIboard/myriInterface.c Fri Sep 10 15:20:41 1999 @@ -1,5 +1,10 @@ /* myriInterface.c */ +#if defined(LFC_SAFE_RESET) && defined(linux) && defined(__KERNEL) +#include +#define printf printk +#else #include +#endif /************************************************************************* * * * Myricom Myrinet Software * @@ -705,8 +710,34 @@ * little endian. E.g., many PowerPC boards are big endian, but * a little endian PCI bus. */ +#if defined(LFC_SAFE_RESET) + /* Try to avoid a reset when the NIC is in a potentially + * dangerous state, e.g., doing a DMA. + */ + unsigned int regs0[16]; + unsigned int regs1[16]; +#define get_regs(regs, unit) { \ + regs[0] = mx_ntohl(ISR(unit)); \ + regs[1] = mx_ntohl(DMA_CTR(unit)); \ + regs[2] = mx_ntohl(EAR(unit)); \ + regs[3] = mx_ntohl(LAR(unit)); \ + } +#if defined(DEBUG) +#define print_regs(msg, regs) { \ + printf("%s: ISR %x DMA_CTR %x EAR %x LAR %x\n", \ + msg, regs[0], regs[1], regs[2], regs[3]); \ + } +#else +#define print_regs(msg, regs) {} +#endif +#endif /* LFC_SAFE_RESET */ if (LANAI_CONTROL[unit]) { +#if defined(LFC_SAFE_RESET) + int trying = 0; + again: + get_regs(regs0, unit); +#endif /* LFC_SAFE_RESET */ switch (action) { case LANAI_RESET_ON: @@ -723,6 +754,53 @@ lanai_ereset_unit(unit, 0); } else { +#if defined(LFC_SAFE_RESET) + if (trying == 0) { + unsigned wait0, wait1, isr; + + /* First check if the LCP honors the LAN1_SIG "safe reset" protocol */ + if (mx_ntohs(LANAI_EEPROM[unit]->lanai_cpu_version) + >= (unsigned short) 0x0500) { + LANAI5_SPECIAL[unit]->ISR = mx_htonl(LAN1_SIG_BIT); + } else { + LANAI_SPECIAL[unit]->ISR = mx_htonl(LAN1_SIG_BIT); + } + + /* wait a short while for the LCP to honour the LAN1_SIG request */ + for (wait0 = 0; wait0 < 10; wait0++) { + for (wait1 = 0; wait1 < 1000; wait1++) { + } + mx_MB; + isr = mx_ntohl(ISR(unit)); + if ((isr & LAN1_SIG_BIT) == 0) { + /* Good! The LCP will no longer DMA */ + /* printf("reset LANAI: LCP acks (ISR %x)\n", isr); */ + *(unsigned int *) &LANAI_CONTROL[unit][0] = + cx_htonl(LANAI_RESET_ON); + mx_MB; + return; + } + } + /* printf("reset LANAI: LCP didn't ack (ISR %x)\n", isr); */ + } + + /* Old LCP; we don't have a completely safe reset procedure */ + mx_MB; + get_regs(regs1, unit); + mx_MB; + if (regs1[0] != regs0[0] || + regs1[1] != 0 || + regs1[1] != regs0[1] || + regs1[2] != regs0[2] || + regs1[3] != regs0[3]) + { + print_regs("DMA pending? regs0", regs0); + print_regs("DMA pending? regs1", regs1); + if (++trying < 10) { + goto again; + } + } +#endif /* LFC_SAFE_RESET */ *(unsigned int *) &LANAI_CONTROL[unit][0] = cx_htonl(LANAI_RESET_ON); } --- myrinet-322c.orig/src/intel_linux/dev/Makefile Sat Dec 27 22:11:47 1997 +++ myrinet-322c/src/intel_linux/dev/Makefile Mon Sep 20 09:45:13 1999 @@ -30,7 +30,11 @@ #CC = $(COMPILER) -g -D$(ARCH) $(HOST_LIBRARY_COMPILER_FLAGS) -DNOTOUCH #list of include directories -INCLUDE_DIRS = -I$(MHOME)/include -I$(MHOME)/lib/lanai +# MUST include bfd.h from LANai include directory (NOT default one!): +include $(MHOME)/make/lanai +#INCLUDE_DIRS = -I$(MHOME)/include -I$(MHOME)/lib/lanai +INCLUDE_DIRS = -I$(LANAI3_TOOLS)/../include -I$(MHOME)/include -I$(MHOME)/lib/lanai + #list of include files INCLUDES = $(MHOME)/include/lanai_device.h $(MHOME)/include/MyrinetPCI.h \ --- myrinet-322c.orig/src/intel_linux/module/Makefile Thu Jan 7 21:04:57 1999 +++ myrinet-322c/src/intel_linux/module/Makefile Thu Sep 16 11:16:40 1999 @@ -23,8 +23,11 @@ # other Myrinet drivers with larger MTU +#CFLAGS = -Wall -Wstrict-prototypes \ +# -D$(ARCH) -D_KERNEL_ -D_KERNEL -D__KERNEL CFLAGS = -Wall -Wstrict-prototypes \ - -D$(ARCH) -D_KERNEL_ -D_KERNEL -D__KERNEL + -D$(ARCH) -D_KERNEL_ -D_KERNEL -D__KERNEL \ + -DLFC_SUPPORT -DLFC_IDLE_CODE -DLFC_SAFE_RESET #-DLANAI_ACCESS_EXPENSIVE @@ -33,9 +36,9 @@ CFLAGS.dec_linux = -DPRINT_LEVEL=0 -mno-fp-regs -ffixed-8 -O2 -DSMALL_BUFFER LFLAGS.dec_linux = -dc -CC = gcc $(CFLAGS) $(CFLAGS.$(ARCH)) +CC = $(COMPILER) $(CFLAGS) $(CFLAGS.$(ARCH)) -CPLUS = g++ -static -DASSERT $(CFLAGS) $(CFLAGS.$(ARCH)) +CPLUS = $(CPLUSPLUS_COMPILER) -static -DASSERT $(CFLAGS) $(CFLAGS.$(ARCH)) all intel_linux dec_linux: $(OBJDIR)/myrinet \ $(OBJDIR)/myrinet_noint \ --- myrinet-322c.orig/src/intel_linux/module/init.c Thu Nov 19 00:26:09 1998 +++ myrinet-322c/src/intel_linux/module/init.c Fri Sep 10 15:24:26 1999 @@ -396,6 +396,12 @@ #endif CLI_STI +#ifdef LFC_IDLE_CODE + if (!interrupts) { + myriApiLoadLanai_idle(unit); + } else { +#endif + PRINTF(1) (" calling myriApiLoadLanai\n"); myriApiLoadLanai(unit, 0xF, MYRI_RECEIVE_INTERRUPT_MASK, aptr); @@ -409,6 +415,10 @@ /* interrupts off, just load LANai, no buffers or interrupts */ myri_reinit(unit, 0); } + +#ifdef LFC_IDLE_CODE + } +#endif #ifdef CLI_STI --- myrinet-322c.orig/src/intel_linux/module/mlanai.c Thu Nov 19 00:10:52 1998 +++ myrinet-322c/src/intel_linux/module/mlanai.c Thu Sep 16 12:02:37 1999 @@ -76,6 +76,9 @@ #include "lanai_device.h" #include "MyrinetPCI.h" #include "myriApiExternal.h" +#if defined(LFC_SUPPORT) +#include "myriApi.h" +#endif /* @@ -458,8 +461,19 @@ */ if (mlanai_private[minor].myriP) { +#if defined(LFC_SUPPORT) + if (mlanai_private[minor].myriP->use_count > 0) { + /* only allow one owner */ + return (-EBUSY); + } +#endif mlanai_private[minor].major = major; mlanai_private[minor].minor = minor; +#if defined(LFC_SUPPORT) + mlanai_private[minor].myriP->owner_task = current; + mlanai_private[minor].myriP->use_count++; + myri_inc_use_count(); +#endif fileP->private_data = &mlanai_private[minor]; return (0); } @@ -469,10 +483,27 @@ } -#ifdef LINUX_20 +#if defined(LINUX_20) || defined(LFC_SUPPORT) +#if defined(LINUX_21) +int +#else void +#endif mlanai_release(struct inode *inodeP, struct file *fileP) { +#if defined(LFC_SUPPORT) + int minor = MINOR(inodeP->i_rdev); + + mlanai_private[minor].myriP->owner_task = NULL; + mlanai_private[minor].myriP->use_count--; +#ifdef LFC_IDLE_CODE + if (mlanai_private[minor].myriP->use_count == 0) { + myriApiLoadLanai_idle(minor); + } +#endif + + myri_dec_use_count(); +#else /* !LFC_SUPPORT */ /* int minor = MINOR(inodeP->i_rdev); int major = MAJOR(inodeP->i_rdev); @@ -480,7 +511,11 @@ PRINTF(5)("mlanai_release(%p, %p)\n", inodeP, fileP); PRINTF(5)("mlanai_release: major = %d minor = %d\n", major, minor); */ +#endif +#if defined(LINUX_21) + return 0; +#endif } #endif @@ -494,7 +529,10 @@ mlanai_ioctl, /* ioctl */ mlanai_mmap, /* mmap */ mlanai_open, /* open */ -#ifdef LINUX_20 +#if defined(LINUX_21) + NULL, /* flush */ +#endif +#if defined(LINUX_20) || defined(LFC_SUPPORT) mlanai_release, /* release */ #else NULL, /* release */ --- myrinet-322c.orig/src/intel_linux/module/myri.c Fri Jan 8 09:20:55 1999 +++ myrinet-322c/src/intel_linux/module/myri.c Thu Sep 16 11:18:40 1999 @@ -216,6 +216,9 @@ extern struct device thisMYRI; struct device thisMYRI1[16]; +#ifdef LFC_IDLE_CODE +extern int myri_load_idle(int unit); +#endif static char * cli_string #ifdef CLI_STI @@ -326,6 +329,10 @@ mp->dev = dev; mp->unit = num_units; +#if defined(LFC_SUPPORT) + mp->owner_task = NULL; + mp->use_count = 0; +#endif /* create storage space for the device name */ dev->name = mlanai_private[num_units].devname; @@ -467,6 +474,20 @@ return (status); } +#if defined(LFC_SUPPORT) +void +myri_inc_use_count(void) +{ + MOD_INC_USE_COUNT; +} + +void +myri_dec_use_count(void) +{ + MOD_DEC_USE_COUNT; +} +#endif + static int myri_open(struct device *dev) { @@ -474,6 +495,12 @@ int i, status = 0; long imr; +#if defined(LFC_SUPPORT) + if (lp->use_count > 0) { + return (-EBUSY); + } +#endif + /* * * Wake up the adapter */ @@ -509,6 +536,9 @@ } MOD_INC_USE_COUNT; +#if defined(LFC_SUPPORT) + lp->use_count++; +#endif return status; } @@ -638,6 +668,14 @@ */ MOD_DEC_USE_COUNT; +#if defined(LFC_SUPPORT) + lp->use_count--; +#if defined(LFC_IDLE_CODE) + if (lp->use_count == 0) { + myriApiLoadLanai_idle(lp->unit); + } +#endif +#endif return 0; } --- myrinet-322c.orig/src/intel_linux/module/myri.h Thu Oct 29 00:01:37 1998 +++ myrinet-322c/src/intel_linux/module/myri.h Thu Sep 16 11:18:55 1999 @@ -145,6 +145,10 @@ int reset_counter; int revision; long in_interrupt; +#if defined(LFC_SUPPORT) + int use_count; /* only allow one owner */ + struct task_struct *owner_task; +#endif }; @@ -187,6 +191,10 @@ extern int mlanai_init(struct myri_private * myriP); extern int mlanai_uninit(struct myri_private * myriP); +#if defined(LFC_SUPPORT) +extern void myri_inc_use_count(void); +extern void myri_dec_use_count(void); +#endif --- myrinet-322c.orig/src/intel_linux/module/receiver.c Fri Jan 8 20:21:51 1999 +++ myrinet-322c/src/intel_linux/module/receiver.c Mon Sep 13 12:15:52 1999 @@ -101,6 +101,17 @@ /* check to see if the LANai wants to handshake */ +#if defined(LFC_SUPPORT) + if (lp->owner_task != NULL) { + PRINTF(INTERRUPTS) ("myri_handle_interrupt[%d]: myriApiInterruptEnable\n", unit); + lanai_interrupt_clear(unit); + send_sig(SIGIO, lp->owner_task, 1); + clear_bit(0, (void *)&lp->in_interrupt); + myriApiInterruptEnable(unit); + return; + } +#endif + if (myriApiWasReset(unit, KERNEL_CHANNEL)) { myri_handle_reset(unit); } diff -Naur myrinet-322c.orig/src/lanai/idlelcp/Makefile myrinet-322c/src/lanai/idlelcp/Makefile --- myrinet-322c.orig/src/lanai/idlelcp/Makefile Thu Jan 1 01:00:00 1970 +++ myrinet-322c/src/lanai/idlelcp/Makefile Mon Sep 13 13:06:20 1999 @@ -0,0 +1,34 @@ +root = ../../.. +include $(root)/make/lanai + +DEFINES = +INCLUDES = -I$(root)/include + +LIB = $(root)/lib/lanai +SCRIPTS = $(root)/bin/scripts + +SRCS := $(shell ls *.c) +OBJS = $(SRCS:%.c=obj/%.lan_o) + +sparc_sunOS: $(LIB)/lcp.idle.dat $(LIB)/myri_code4_idle.h + +$(LIB)/lcp.idle.dat: obj/lcp.idle + rm -f $@ + $(LANAI3_GENDAT) obj/lcp.idle > $@ + chmod a+rwx $@ + +obj/lcp.idle: $(OBJS) crt0.o + $(LANAI3_LINKER) -o $@ crt0.o $(OBJS) -lgcc -nostdlib + +obj/%.lan_o : %.c + $(LANAI3_COMPILER) $(DEFINES) $(INCLUDES) -c -g $< -o $@ + +$(LIB)/myri_code4_idle.h: $(LIB)/lcp.idle.dat + cat $(LIB)/lcp.idle.dat | $(SCRIPTS)/convert.pl 4 char | \ + sed 's/lanai4_/lanai4_idle_/' > $@ + +clean: + /bin/rm -f obj/* + +crt0.o: ../mcp/crt0.s + $(LANAI3_GCC_TOOLS)/lanai3-gcc -c ../mcp/crt0.s diff -Naur myrinet-322c.orig/src/lanai/idlelcp/idlelcp.c myrinet-322c/src/lanai/idlelcp/idlelcp.c --- myrinet-322c.orig/src/lanai/idlelcp/idlelcp.c Thu Jan 1 01:00:00 1970 +++ myrinet-322c/src/lanai/idlelcp/idlelcp.c Fri Sep 10 16:44:28 1999 @@ -0,0 +1,71 @@ +/* Dummy LCP that does nothing except drain the network. + * + * Author: Raoul Bhoedjang + * Created: 14 Aug. 1997 + * + * Modified: Kees Verstoep + * Dec 21, 1998: acknowledge reset interrupts from host + */ + +#include + +#define RECVSIZE 1024 /* unsigned ints */ + +#define isr_delay() asm volatile("nop; nop; nop") +#define dotouch(isr) touch(isr) + +static unsigned recvbuf[RECVSIZE + 1]; /* +1 for CRC */ + +static void +lanai_init(void) +{ + EIMR = 0x0; /* don't generate external interrupts */ + IMR = 0x0; + ISR = 0xFFFFFFFF; /* clear all interrupt status */ + + /* LANai4.X */ + MYRINET = NRES_ENABLE_BIT | CRC_ENABLE_BIT; + VERSION = 3; + TIMEOUT = 1; /* 1/4 second should be enough */ + + if (ISR & LINK_INT_BIT) { + clear_LINK_INT_BIT(); + } +} + + +static void +drain_network(void) +{ + if ((ISR & BYTE_RDY_BIT) == 0) { + return; + } + + RMP = &recvbuf[0]; + RML = &recvbuf[RECVSIZE - 1]; + + isr_delay(); + while ((ISR & (RECV_INT_BIT|BUFF_INT_BIT)) == 0) { + dotouch(ISR); + } +} + + +int +main(void) +{ + lanai_init(); + + while(1) { + drain_network(); + + /* acknowledge pending reset by host */ + dotouch(ISR); + if ((ISR & LAN1_SIG_BIT) != 0) { + ISR = LAN1_SIG_BIT; + } + dotouch(ISR); + } + + return 0; +} --- myrinet-322c.orig/src/sparc_sunOS/api/myriApi.c Thu Jul 23 20:13:27 1998 +++ myrinet-322c/src/sparc_sunOS/api/myriApi.c Mon Sep 13 09:20:02 1999 @@ -62,6 +62,9 @@ #include "myri_code4.h" #endif #endif +#if defined(LFC_IDLE_CODE) +#include "myri_code4_idle.h" +#endif #define SHAKE_TRIES 100 @@ -699,6 +702,41 @@ #endif } +#if defined(LFC_IDLE_CODE) +void +myriApiLoadLanai_idle(int unit) +{ + unsigned int i; + + lanai_reset_unit(unit, ON); + + for (i = 0; i < lanai_memory_size(unit); i += 4) + { + lanai_write_word(unit, i, 0); + } + + + /* copy the object code */ + + for (i = 0; i < sizeof(lanai4_idle_code); i++) + { + lanai_write_byte(unit, ((lanai4_idle_code_off * 2) + i), + lanai4_idle_code[i]); + } + + + /* copy the data */ + + for (i = 0; i < sizeof(lanai4_idle_data); i++) + { + lanai_write_byte(unit, ((lanai4_idle_data_off * 2) + i), + lanai4_idle_data[i]); + } + + lanai_reset_unit(unit, OFF); + +} +#endif /* LFC_IDLE_CODE */ void