Index: head/sys/conf/files.amd64 =================================================================== --- head/sys/conf/files.amd64 (revision 351136) +++ head/sys/conf/files.amd64 (revision 351137) @@ -1,458 +1,459 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # # $FreeBSD$ # # common files stuff between i386 and amd64 include "conf/files.x86" # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # # cloudabi32_vdso.o optional compat_cloudabi32 \ dependency "$S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S" \ compile-with "${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "cloudabi32_vdso.o" # cloudabi32_vdso_blob.o optional compat_cloudabi32 \ dependency "cloudabi32_vdso.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi32_vdso.o ${.TARGET}" \ no-implicit-rule \ clean "cloudabi32_vdso_blob.o" # cloudabi64_vdso.o optional compat_cloudabi64 \ dependency "$S/contrib/cloudabi/cloudabi_vdso_x86_64.S" \ compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_x86_64.S -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "cloudabi64_vdso.o" # cloudabi64_vdso_blob.o optional compat_cloudabi64 \ dependency "cloudabi64_vdso.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi64_vdso.o ${.TARGET}" \ no-implicit-rule \ clean "cloudabi64_vdso_blob.o" # linux32_genassym.o optional compat_linux32 \ dependency "$S/amd64/linux32/linux32_genassym.c offset.inc" \ compile-with "${CC} ${CFLAGS:N-flto:N-fno-common} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "linux32_genassym.o" # linux32_assym.h optional compat_linux32 \ dependency "$S/kern/genassym.sh linux32_genassym.o" \ compile-with "sh $S/kern/genassym.sh linux32_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "linux32_assym.h" # linux32_locore.o optional compat_linux32 \ dependency "linux32_assym.h $S/amd64/linux32/linux32_locore.asm" \ compile-with "${CC} -x assembler-with-cpp -DLOCORE -m32 -shared -s -pipe -I. -I$S -Werror -Wall -fPIC -fno-common -nostdinc -nostdlib -Wl,-T$S/amd64/linux32/linux32_vdso.lds.s -Wl,-soname=linux32_vdso.so,--eh-frame-hdr,-warn-common ${.IMPSRC} -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "linux32_locore.o" # linux32_vdso.so optional compat_linux32 \ dependency "linux32_locore.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 linux32_locore.o ${.TARGET}" \ no-implicit-rule \ clean "linux32_vdso.so" # ia32_genassym.o standard \ dependency "$S/compat/ia32/ia32_genassym.c offset.inc" \ compile-with "${CC} ${CFLAGS:N-flto:N-fno-common} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "ia32_genassym.o" # ia32_assym.h standard \ dependency "$S/kern/genassym.sh ia32_genassym.o" \ compile-with "env NM='${NM}' NMFLAGS='${NMFLAGS}' sh $S/kern/genassym.sh ia32_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "ia32_assym.h" # font.h optional sc_dflt_font \ compile-with "uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'static u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'static u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'static u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h" \ no-obj no-implicit-rule before-depend \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" # atkbdmap.h optional atkbd_dflt_keymap \ compile-with "kbdcontrol -P ${S:S/sys$/share/}/vt/keymaps -P ${S:S/sys$/share/}/syscons/keymaps -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "atkbdmap.h" # amd64/acpica/acpi_machdep.c optional acpi acpi_wakecode.o optional acpi \ dependency "$S/amd64/acpica/acpi_wakecode.S assym.inc" \ compile-with "${NORMAL_S}" \ no-obj no-implicit-rule before-depend \ clean "acpi_wakecode.o" acpi_wakecode.bin optional acpi \ dependency "acpi_wakecode.o" \ compile-with "${OBJCOPY} -S -O binary acpi_wakecode.o ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "acpi_wakecode.bin" acpi_wakecode.h optional acpi \ dependency "acpi_wakecode.bin" \ compile-with "file2c -sx 'static char wakecode[] = {' '};' < acpi_wakecode.bin > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "acpi_wakecode.h" acpi_wakedata.h optional acpi \ dependency "acpi_wakecode.o" \ compile-with '${NM} -n --defined-only acpi_wakecode.o | while read offset dummy what; do echo "#define $${what} 0x$${offset}"; done > ${.TARGET}' \ no-obj no-implicit-rule before-depend \ clean "acpi_wakedata.h" # #amd64/amd64/apic_vector.S standard amd64/amd64/bios.c standard amd64/amd64/bpf_jit_machdep.c optional bpf_jitter amd64/amd64/copyout.c standard amd64/amd64/cpu_switch.S standard amd64/amd64/db_disasm.c optional ddb amd64/amd64/db_interface.c optional ddb amd64/amd64/db_trace.c optional ddb amd64/amd64/efirt_machdep.c optional efirt amd64/amd64/efirt_support.S optional efirt amd64/amd64/elf_machdep.c standard amd64/amd64/exception.S standard amd64/amd64/fpu.c standard amd64/amd64/gdb_machdep.c optional gdb amd64/amd64/in_cksum.c optional inet | inet6 amd64/amd64/initcpu.c standard amd64/amd64/io.c optional io amd64/amd64/locore.S standard no-obj amd64/amd64/xen-locore.S optional xenhvm amd64/amd64/machdep.c standard amd64/amd64/mem.c optional mem amd64/amd64/minidump_machdep.c standard amd64/amd64/mp_machdep.c optional smp amd64/amd64/mpboot.S optional smp amd64/amd64/pmap.c standard amd64/amd64/prof_machdep.c optional profiling-routine amd64/amd64/ptrace_machdep.c standard amd64/amd64/sigtramp.S standard amd64/amd64/support.S standard amd64/amd64/sys_machdep.c standard amd64/amd64/trap.c standard amd64/amd64/uio_machdep.c standard amd64/amd64/uma_machdep.c standard amd64/amd64/vm_machdep.c standard amd64/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 amd64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 amd64/pci/pci_cfgreg.c optional pci cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S optional zfs | dtrace compile-with "${ZFS_S}" cddl/dev/dtrace/amd64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/amd64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_amd64.S optional aesni crypto/blowfish/bf_enc.c optional crypto | ipsec | ipsec_support crypto/des/des_enc.c optional crypto | ipsec | \ ipsec_support | netsmb dev/acpi_support/acpi_wmi_if.m standard dev/agp/agp_amd64.c optional agp dev/agp/agp_i810.c optional agp dev/agp/agp_via.c optional agp dev/amdgpio/amdgpio.c optional amdgpio dev/amdsbwd/amdsbwd.c optional amdsbwd dev/amdsmn/amdsmn.c optional amdsmn | amdtemp dev/amdtemp/amdtemp.c optional amdtemp dev/arcmsr/arcmsr.c optional arcmsr pci dev/asmc/asmc.c optional asmc isa dev/atkbdc/atkbd.c optional atkbd atkbdc dev/atkbdc/atkbd_atkbdc.c optional atkbd atkbdc dev/atkbdc/atkbdc.c optional atkbdc dev/atkbdc/atkbdc_isa.c optional atkbdc isa dev/atkbdc/atkbdc_subr.c optional atkbdc dev/atkbdc/psm.c optional psm atkbdc dev/coretemp/coretemp.c optional coretemp dev/cpuctl/cpuctl.c optional cpuctl dev/dpms/dpms.c optional dpms dev/fb/fb.c optional fb | vga dev/fb/s3_pci.c optional s3pci dev/fb/vesa.c optional vga vesa dev/fb/vga.c optional vga dev/ichwd/ichwd.c optional ichwd dev/if_ndis/if_ndis.c optional ndis dev/if_ndis/if_ndis_pccard.c optional ndis pccard dev/if_ndis/if_ndis_pci.c optional ndis cardbus | ndis pci dev/if_ndis/if_ndis_usb.c optional ndis usb dev/imcsmb/imcsmb.c optional imcsmb dev/imcsmb/imcsmb_pci.c optional imcsmb pci dev/intel/spi.c optional intelspi dev/io/iodev.c optional io dev/ioat/ioat.c optional ioat pci dev/ioat/ioat_test.c optional ioat pci dev/ixl/if_ixl.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_pf_main.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_pf_qmgr.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_pf_iov.c optional ixl pci pci_iov \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_pf_i2c.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/if_iavf.c optional iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/iavf_vc.c optional iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/ixl_txrx.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_osdep.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_lan_hmc.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_hmc.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_common.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_nvm.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_adminq.c optional ixl pci | iavf pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/ixl/i40e_dcb.c optional ixl pci \ compile-with "${NORMAL_C} -I$S/dev/ixl" dev/gpio/bytgpio.c optional bytgpio dev/gpio/chvgpio.c optional chvgpio dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv dev/nctgpio/nctgpio.c optional nctgpio dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb dev/ntb/ntb_transport.c optional ntb_transport | if_ntb dev/ntb/ntb.c optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw dev/ntb/ntb_if.m optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw dev/ntb/ntb_hw/ntb_hw_amd.c optional ntb_hw_amd | ntb_hw dev/ntb/ntb_hw/ntb_hw_intel.c optional ntb_hw_intel | ntb_hw dev/ntb/ntb_hw/ntb_hw_plx.c optional ntb_hw_plx | ntb_hw +dev/ntb/test/ntb_tool.c optional ntb_tool dev/nvram/nvram.c optional nvram isa dev/random/ivy.c optional rdrand_rng !random_loadable dev/random/nehemiah.c optional padlock_rng !random_loadable dev/qlxge/qls_dbg.c optional qlxge pci dev/qlxge/qls_dump.c optional qlxge pci dev/qlxge/qls_hw.c optional qlxge pci dev/qlxge/qls_ioctl.c optional qlxge pci dev/qlxge/qls_isr.c optional qlxge pci dev/qlxge/qls_os.c optional qlxge pci dev/qlxgb/qla_dbg.c optional qlxgb pci dev/qlxgb/qla_hw.c optional qlxgb pci dev/qlxgb/qla_ioctl.c optional qlxgb pci dev/qlxgb/qla_isr.c optional qlxgb pci dev/qlxgb/qla_misc.c optional qlxgb pci dev/qlxgb/qla_os.c optional qlxgb pci dev/qlxgbe/ql_dbg.c optional qlxgbe pci dev/qlxgbe/ql_hw.c optional qlxgbe pci dev/qlxgbe/ql_ioctl.c optional qlxgbe pci dev/qlxgbe/ql_isr.c optional qlxgbe pci dev/qlxgbe/ql_misc.c optional qlxgbe pci dev/qlxgbe/ql_os.c optional qlxgbe pci dev/qlxgbe/ql_reset.c optional qlxgbe pci dev/qlxgbe/ql_fw.c optional qlxgbe pci dev/qlxgbe/ql_boot.c optional qlxgbe pci dev/qlxgbe/ql_minidump.c optional qlxgbe pci dev/qlnx/qlnxe/ecore_cxt.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_dbg_fw_funcs.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_dcbx.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_dev.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_hw.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_init_fw_funcs.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_init_ops.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_int.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_l2.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_mcp.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_sp_commands.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/ecore_spq.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/qlnx_ioctl.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/qlnx/qlnxe/qlnx_os.c optional qlnxe pci \ compile-with "${LINUXKPI_C}" dev/sfxge/common/ef10_ev.c optional sfxge pci dev/sfxge/common/ef10_filter.c optional sfxge pci dev/sfxge/common/ef10_image.c optional sfxge pci dev/sfxge/common/ef10_intr.c optional sfxge pci dev/sfxge/common/ef10_mac.c optional sfxge pci dev/sfxge/common/ef10_mcdi.c optional sfxge pci dev/sfxge/common/ef10_nic.c optional sfxge pci dev/sfxge/common/ef10_nvram.c optional sfxge pci dev/sfxge/common/ef10_phy.c optional sfxge pci dev/sfxge/common/ef10_rx.c optional sfxge pci dev/sfxge/common/ef10_tx.c optional sfxge pci dev/sfxge/common/ef10_vpd.c optional sfxge pci dev/sfxge/common/efx_bootcfg.c optional sfxge pci dev/sfxge/common/efx_crc32.c optional sfxge pci dev/sfxge/common/efx_ev.c optional sfxge pci dev/sfxge/common/efx_filter.c optional sfxge pci dev/sfxge/common/efx_hash.c optional sfxge pci dev/sfxge/common/efx_intr.c optional sfxge pci dev/sfxge/common/efx_lic.c optional sfxge pci dev/sfxge/common/efx_mac.c optional sfxge pci dev/sfxge/common/efx_mcdi.c optional sfxge pci dev/sfxge/common/efx_mon.c optional sfxge pci dev/sfxge/common/efx_nic.c optional sfxge pci dev/sfxge/common/efx_nvram.c optional sfxge pci dev/sfxge/common/efx_phy.c optional sfxge pci dev/sfxge/common/efx_port.c optional sfxge pci dev/sfxge/common/efx_rx.c optional sfxge pci dev/sfxge/common/efx_sram.c optional sfxge pci dev/sfxge/common/efx_tunnel.c optional sfxge pci dev/sfxge/common/efx_tx.c optional sfxge pci dev/sfxge/common/efx_vpd.c optional sfxge pci dev/sfxge/common/hunt_nic.c optional sfxge pci dev/sfxge/common/mcdi_mon.c optional sfxge pci dev/sfxge/common/medford_nic.c optional sfxge pci dev/sfxge/common/medford2_nic.c optional sfxge pci dev/sfxge/common/siena_mac.c optional sfxge pci dev/sfxge/common/siena_mcdi.c optional sfxge pci dev/sfxge/common/siena_nic.c optional sfxge pci dev/sfxge/common/siena_nvram.c optional sfxge pci dev/sfxge/common/siena_phy.c optional sfxge pci dev/sfxge/common/siena_sram.c optional sfxge pci dev/sfxge/common/siena_vpd.c optional sfxge pci dev/sfxge/sfxge.c optional sfxge pci dev/sfxge/sfxge_dma.c optional sfxge pci dev/sfxge/sfxge_ev.c optional sfxge pci dev/sfxge/sfxge_intr.c optional sfxge pci dev/sfxge/sfxge_mcdi.c optional sfxge pci dev/sfxge/sfxge_nvram.c optional sfxge pci dev/sfxge/sfxge_port.c optional sfxge pci dev/sfxge/sfxge_rx.c optional sfxge pci dev/sfxge/sfxge_tx.c optional sfxge pci dev/sio/sio.c optional sio dev/sio/sio_isa.c optional sio isa dev/sio/sio_pccard.c optional sio pccard dev/sio/sio_pci.c optional sio pci dev/sio/sio_puc.c optional sio puc dev/smartpqi/smartpqi_cam.c optional smartpqi dev/smartpqi/smartpqi_cmd.c optional smartpqi dev/smartpqi/smartpqi_discovery.c optional smartpqi dev/smartpqi/smartpqi_event.c optional smartpqi dev/smartpqi/smartpqi_helper.c optional smartpqi dev/smartpqi/smartpqi_init.c optional smartpqi dev/smartpqi/smartpqi_intr.c optional smartpqi dev/smartpqi/smartpqi_ioctl.c optional smartpqi dev/smartpqi/smartpqi_main.c optional smartpqi dev/smartpqi/smartpqi_mem.c optional smartpqi dev/smartpqi/smartpqi_misc.c optional smartpqi dev/smartpqi/smartpqi_queue.c optional smartpqi dev/smartpqi/smartpqi_request.c optional smartpqi dev/smartpqi/smartpqi_response.c optional smartpqi dev/smartpqi/smartpqi_sis.c optional smartpqi dev/smartpqi/smartpqi_tag.c optional smartpqi dev/speaker/spkr.c optional speaker dev/superio/superio.c optional superio isa dev/syscons/apm/apm_saver.c optional apm_saver apm dev/syscons/scvesactl.c optional sc vga vesa dev/syscons/scvgarndr.c optional sc vga dev/tpm/tpm.c optional tpm dev/tpm/tpm20.c optional tpm dev/tpm/tpm_crb.c optional tpm acpi dev/tpm/tpm_tis.c optional tpm acpi dev/tpm/tpm_acpi.c optional tpm acpi dev/tpm/tpm_isa.c optional tpm isa dev/uart/uart_cpu_x86.c optional uart dev/viawd/viawd.c optional viawd dev/vmware/vmxnet3/if_vmx.c optional vmx dev/vmware/vmci/vmci.c optional vmci dev/vmware/vmci/vmci_datagram.c optional vmci dev/vmware/vmci/vmci_doorbell.c optional vmci dev/vmware/vmci/vmci_driver.c optional vmci dev/vmware/vmci/vmci_event.c optional vmci dev/vmware/vmci/vmci_hashtable.c optional vmci dev/vmware/vmci/vmci_kernel_if.c optional vmci dev/vmware/vmci/vmci_qpair.c optional vmci dev/vmware/vmci/vmci_queue_pair.c optional vmci dev/vmware/vmci/vmci_resource.c optional vmci dev/wbwd/wbwd.c optional wbwd dev/xen/pci/xen_acpi_pci.c optional xenhvm dev/xen/pci/xen_pci.c optional xenhvm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/kern_clocksource.c standard kern/imgact_aout.c optional compat_aout kern/link_elf_obj.c standard # # IA32 binary support # #amd64/ia32/ia32_exception.S optional compat_freebsd32 amd64/ia32/ia32_reg.c optional compat_freebsd32 amd64/ia32/ia32_signal.c optional compat_freebsd32 amd64/ia32/ia32_sigtramp.S optional compat_freebsd32 amd64/ia32/ia32_syscall.c optional compat_freebsd32 amd64/ia32/ia32_misc.c optional compat_freebsd32 compat/ia32/ia32_sysvec.c optional compat_freebsd32 compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs # # Linux/i386 binary support # amd64/linux32/linux32_dummy.c optional compat_linux32 amd64/linux32/linux32_machdep.c optional compat_linux32 amd64/linux32/linux32_support.s optional compat_linux32 \ dependency "linux32_assym.h" amd64/linux32/linux32_sysent.c optional compat_linux32 amd64/linux32/linux32_sysvec.c optional compat_linux32 compat/linux/linux_emul.c optional compat_linux32 compat/linux/linux_errno.c optional compat_linux32 compat/linux/linux_file.c optional compat_linux32 compat/linux/linux_fork.c optional compat_linux32 compat/linux/linux_futex.c optional compat_linux32 compat/linux/linux_getcwd.c optional compat_linux32 compat/linux/linux_ioctl.c optional compat_linux32 compat/linux/linux_ipc.c optional compat_linux32 compat/linux/linux_mib.c optional compat_linux32 compat/linux/linux_misc.c optional compat_linux32 compat/linux/linux_mmap.c optional compat_linux32 compat/linux/linux_signal.c optional compat_linux32 compat/linux/linux_socket.c optional compat_linux32 compat/linux/linux_stats.c optional compat_linux32 compat/linux/linux_sysctl.c optional compat_linux32 compat/linux/linux_time.c optional compat_linux32 compat/linux/linux_timer.c optional compat_linux32 compat/linux/linux_uid16.c optional compat_linux32 compat/linux/linux_util.c optional compat_linux32 compat/linux/linux_vdso.c optional compat_linux32 compat/linux/linux_common.c optional compat_linux32 compat/linux/linux_event.c optional compat_linux32 compat/linux/linux.c optional compat_linux32 dev/amr/amr_linux.c optional compat_linux32 amr dev/mfi/mfi_linux.c optional compat_linux32 mfi compat/ndis/winx64_wrap.S optional ndisapi pci # # x86 real mode BIOS emulator, required by dpms/pci/vesa # compat/x86bios/x86bios.c optional x86bios | dpms | pci | vesa contrib/x86emu/x86emu.c optional x86bios | dpms | pci | vesa # # bvm console # dev/bvm/bvm_console.c optional bvmconsole dev/bvm/bvm_dbg.c optional bvmdebug # Common files where we currently configure the system differently, but perhaps shouldn't # config(8) doesn't have a way to force standard options, so we've been inconsistent # about marking non-optional things 'standard'. x86/acpica/madt.c optional acpi x86/isa/atpic.c optional atpic isa x86/isa/elcr.c optional atpic isa | mptable x86/isa/isa.c standard x86/isa/isa_dma.c standard x86/pci/pci_early_quirks.c optional pci x86/x86/io_apic.c standard x86/x86/local_apic.c standard x86/x86/mptable.c optional mptable x86/x86/mptable_pci.c optional mptable pci x86/x86/msi.c optional pci x86/xen/pv.c optional xenhvm x86/xen/pvcpu_enum.c optional xenhvm x86/xen/xen_pci_bus.c optional xenhvm Index: head/sys/conf/files.i386 =================================================================== --- head/sys/conf/files.i386 (revision 351136) +++ head/sys/conf/files.i386 (revision 351137) @@ -1,309 +1,310 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # # $FreeBSD$ # # common files stuff between i386 and amd64 include "conf/files.x86" # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # cloudabi32_vdso.o optional compat_cloudabi32 \ dependency "$S/contrib/cloudabi/cloudabi_vdso_i686.S" \ compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686.S -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "cloudabi32_vdso.o" # cloudabi32_vdso_blob.o optional compat_cloudabi32 \ dependency "cloudabi32_vdso.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf32-i386-freebsd --binary-architecture i386 cloudabi32_vdso.o ${.TARGET}" \ no-implicit-rule \ clean "cloudabi32_vdso_blob.o" # linux_genassym.o optional compat_linux \ dependency "$S/i386/linux/linux_genassym.c offset.inc" \ compile-with "${CC} ${CFLAGS:N-flto:N-fno-common} -c ${.IMPSRC}" \ no-obj no-implicit-rule \ clean "linux_genassym.o" # linux_assym.h optional compat_linux \ dependency "$S/kern/genassym.sh linux_genassym.o" \ compile-with "sh $S/kern/genassym.sh linux_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "linux_assym.h" # linux_locore.o optional compat_linux \ dependency "linux_assym.h $S/i386/linux/linux_locore.asm" \ compile-with "${CC} -x assembler-with-cpp -DLOCORE -shared -s -pipe -I. -I$S -Werror -Wall -fPIC -fno-common -nostdinc -nostdlib -Wl,-T$S/i386/linux/linux_vdso.lds.s -Wl,-soname=linux_vdso.so,--eh-frame-hdr,-warn-common ${.IMPSRC} -o ${.TARGET}" \ no-obj no-implicit-rule \ clean "linux_locore.o" # linux_vdso.so optional compat_linux \ dependency "linux_locore.o" \ compile-with "${OBJCOPY} --input-target binary --output-target elf32-i386-freebsd --binary-architecture i386 linux_locore.o ${.TARGET}" \ no-implicit-rule \ clean "linux_vdso.so" # font.h optional sc_dflt_font \ compile-with "uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'static u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'static u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'static u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h" \ no-obj no-implicit-rule before-depend \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" # atkbdmap.h optional atkbd_dflt_keymap \ compile-with "kbdcontrol -P ${S:S/sys$/share/}/vt/keymaps -P ${S:S/sys$/share/}/syscons/keymaps -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \ no-obj no-implicit-rule before-depend \ clean "atkbdmap.h" # cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S optional zfs | dtrace compile-with "${ZFS_S}" cddl/dev/dtrace/i386/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/i386/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs compat/linux/linux_event.c optional compat_linux compat/linux/linux_emul.c optional compat_linux compat/linux/linux_errno.c optional compat_linux compat/linux/linux_file.c optional compat_linux compat/linux/linux_fork.c optional compat_linux compat/linux/linux_futex.c optional compat_linux compat/linux/linux_getcwd.c optional compat_linux compat/linux/linux_ioctl.c optional compat_linux compat/linux/linux_ipc.c optional compat_linux compat/linux/linux_mib.c optional compat_linux compat/linux/linux_misc.c optional compat_linux compat/linux/linux_mmap.c optional compat_linux compat/linux/linux_signal.c optional compat_linux compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux compat/linux/linux_sysctl.c optional compat_linux compat/linux/linux_time.c optional compat_linux compat/linux/linux_timer.c optional compat_linux compat/linux/linux_uid16.c optional compat_linux compat/linux/linux_util.c optional compat_linux compat/linux/linux_vdso.c optional compat_linux compat/linux/linux.c optional compat_linux compat/ndis/winx32_wrap.S optional ndisapi pci bf_enc.o optional crypto | ipsec | ipsec_support \ dependency "$S/crypto/blowfish/arch/i386/bf_enc.S $S/crypto/blowfish/arch/i386/bf_enc_586.S $S/crypto/blowfish/arch/i386/bf_enc_686.S" \ compile-with "${CC} -c -I$S/crypto/blowfish/arch/i386 ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}" \ no-implicit-rule crypto/aesni/aeskeys_i386.S optional aesni crypto/des/arch/i386/des_enc.S optional crypto | ipsec | ipsec_support | netsmb dev/agp/agp_ali.c optional agp dev/agp/agp_amd.c optional agp dev/agp/agp_amd64.c optional agp dev/agp/agp_ati.c optional agp dev/agp/agp_i810.c optional agp dev/agp/agp_intel.c optional agp dev/agp/agp_nvidia.c optional agp dev/agp/agp_sis.c optional agp dev/agp/agp_via.c optional agp dev/amdsbwd/amdsbwd.c optional amdsbwd dev/amdsmn/amdsmn.c optional amdsmn | amdtemp dev/amdtemp/amdtemp.c optional amdtemp dev/arcmsr/arcmsr.c optional arcmsr pci dev/asmc/asmc.c optional asmc isa dev/atkbdc/atkbd.c optional atkbd atkbdc dev/atkbdc/atkbd_atkbdc.c optional atkbd atkbdc dev/atkbdc/atkbdc.c optional atkbdc dev/atkbdc/atkbdc_isa.c optional atkbdc isa dev/atkbdc/atkbdc_subr.c optional atkbdc dev/atkbdc/psm.c optional psm atkbdc dev/ce/ceddk.c optional ce dev/ce/if_ce.c optional ce dev/ce/tau32-ddk.c optional ce \ compile-with "${NORMAL_C} ${NO_WCONSTANT_CONVERSION}" dev/coretemp/coretemp.c optional coretemp dev/cp/cpddk.c optional cp dev/cp/if_cp.c optional cp dev/cpuctl/cpuctl.c optional cpuctl dev/ctau/ctau.c optional ctau dev/ctau/ctddk.c optional ctau dev/ctau/if_ct.c optional ctau dev/cx/csigma.c optional cx dev/cx/cxddk.c optional cx dev/cx/if_cx.c optional cx dev/dpms/dpms.c optional dpms dev/fb/fb.c optional fb | vga dev/fb/s3_pci.c optional s3pci dev/fb/vesa.c optional vga vesa dev/fb/vga.c optional vga dev/glxiic/glxiic.c optional glxiic dev/glxsb/glxsb.c optional glxsb dev/glxsb/glxsb_hash.c optional glxsb dev/gpio/bytgpio.c optional bytgpio dev/gpio/chvgpio.c optional chvgpio dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv dev/ichwd/ichwd.c optional ichwd dev/if_ndis/if_ndis.c optional ndis dev/if_ndis/if_ndis_pccard.c optional ndis pccard dev/if_ndis/if_ndis_pci.c optional ndis cardbus | ndis pci dev/if_ndis/if_ndis_usb.c optional ndis usb dev/imcsmb/imcsmb.c optional imcsmb dev/imcsmb/imcsmb_pci.c optional imcsmb pci dev/intel/spi.c optional intelspi dev/io/iodev.c optional io dev/le/if_le_isa.c optional le isa dev/nctgpio/nctgpio.c optional nctgpio dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb dev/ntb/ntb_transport.c optional ntb_transport | if_ntb dev/ntb/ntb.c optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw dev/ntb/ntb_if.m optional ntb | ntb_transport | if_ntb | ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw dev/ntb/ntb_hw/ntb_hw_amd.c optional ntb_hw_amd | ntb_hw dev/ntb/ntb_hw/ntb_hw_intel.c optional ntb_hw_intel | ntb_hw dev/ntb/ntb_hw/ntb_hw_plx.c optional ntb_hw_plx | ntb_hw +dev/ntb/test/ntb_tool.c optional ntb_tool dev/nvram/nvram.c optional nvram isa dev/ofw/ofwpci.c optional fdt pci dev/pcf/pcf_isa.c optional pcf dev/random/ivy.c optional rdrand_rng !random_loadable dev/random/nehemiah.c optional padlock_rng !random_loadable dev/sbni/if_sbni.c optional sbni dev/sbni/if_sbni_isa.c optional sbni isa dev/sbni/if_sbni_pci.c optional sbni pci dev/sio/sio.c optional sio dev/sio/sio_isa.c optional sio isa dev/sio/sio_pccard.c optional sio pccard dev/sio/sio_pci.c optional sio pci dev/sio/sio_puc.c optional sio puc dev/speaker/spkr.c optional speaker dev/superio/superio.c optional superio isa dev/syscons/apm/apm_saver.c optional apm_saver apm dev/syscons/scvesactl.c optional sc vga vesa dev/syscons/scvgarndr.c optional sc vga dev/tpm/tpm.c optional tpm dev/tpm/tpm_acpi.c optional tpm acpi dev/tpm/tpm_isa.c optional tpm isa dev/uart/uart_cpu_x86.c optional uart dev/viawd/viawd.c optional viawd dev/vmware/vmxnet3/if_vmx.c optional vmx dev/vmware/vmci/vmci.c optional vmci dev/vmware/vmci/vmci_datagram.c optional vmci dev/vmware/vmci/vmci_doorbell.c optional vmci dev/vmware/vmci/vmci_driver.c optional vmci dev/vmware/vmci/vmci_event.c optional vmci dev/vmware/vmci/vmci_hashtable.c optional vmci dev/vmware/vmci/vmci_kernel_if.c optional vmci dev/vmware/vmci/vmci_qpair.c optional vmci dev/vmware/vmci/vmci_queue_pair.c optional vmci dev/vmware/vmci/vmci_resource.c optional vmci dev/acpi_support/acpi_wmi_if.m standard dev/wbwd/wbwd.c optional wbwd i386/acpica/acpi_machdep.c optional acpi acpi_wakecode.o optional acpi \ dependency "$S/i386/acpica/acpi_wakecode.S assym.inc" \ compile-with "${NORMAL_S}" \ no-obj no-implicit-rule before-depend \ clean "acpi_wakecode.o" acpi_wakecode.bin optional acpi \ dependency "acpi_wakecode.o" \ compile-with "${OBJCOPY} -S -O binary acpi_wakecode.o ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "acpi_wakecode.bin" acpi_wakecode.h optional acpi \ dependency "acpi_wakecode.bin" \ compile-with "file2c -sx 'static char wakecode[] = {' '};' < acpi_wakecode.bin > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "acpi_wakecode.h" acpi_wakedata.h optional acpi \ dependency "acpi_wakecode.o" \ compile-with '${NM} -n --defined-only acpi_wakecode.o | while read offset dummy what; do echo "#define $${what} 0x$${offset}"; done > ${.TARGET}' \ no-obj no-implicit-rule before-depend \ clean "acpi_wakedata.h" # i386/bios/apm.c optional apm i386/bios/smapi.c optional smapi i386/bios/smapi_bios.S optional smapi i386/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 #i386/i386/apic_vector.s optional apic i386/i386/bios.c standard i386/i386/bioscall.s standard i386/i386/bpf_jit_machdep.c optional bpf_jitter i386/i386/copyout.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb i386/i386/elan-mmcr.c optional cpu_elan | cpu_soekris i386/i386/elf_machdep.c standard i386/i386/exception.s standard i386/i386/gdb_machdep.c optional gdb i386/i386/geode.c optional cpu_geode i386/i386/in_cksum.c optional inet | inet6 i386/i386/initcpu.c standard i386/i386/io.c optional io i386/i386/k6_mem.c optional mem i386/i386/locore.s standard no-obj i386/i386/longrun.c optional cpu_enable_longrun i386/i386/machdep.c standard i386/i386/mem.c optional mem i386/i386/minidump_machdep.c standard i386/i386/minidump_machdep_pae.c standard i386/i386/minidump_machdep_nopae.c standard i386/i386/mp_clock.c optional smp i386/i386/mp_machdep.c optional smp i386/i386/mpboot.s optional smp i386/i386/npx.c standard i386/i386/perfmon.c optional perfmon i386/i386/pmap_base.c standard i386/i386/pmap_nopae.c standard i386/i386/pmap_pae.c standard i386/i386/prof_machdep.c optional profiling-routine i386/i386/ptrace_machdep.c standard i386/i386/sigtramp.s standard i386/i386/support.s standard i386/i386/swtch.s standard i386/i386/sys_machdep.c standard i386/i386/trap.c standard i386/i386/uio_machdep.c standard i386/i386/vm86.c standard i386/i386/vm_machdep.c standard i386/linux/imgact_linux.c optional compat_linux i386/linux/linux_copyout.c optional compat_linux i386/linux/linux_dummy.c optional compat_linux i386/linux/linux_machdep.c optional compat_linux i386/linux/linux_ptrace.c optional compat_linux i386/linux/linux_sysent.c optional compat_linux i386/linux/linux_sysvec.c optional compat_linux i386/pci/pci_cfgreg.c optional pci i386/pci/pci_pir.c optional pci isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/kern_clocksource.c standard kern/imgact_aout.c optional compat_aout kern/subr_sfbuf.c standard libkern/divdi3.c standard libkern/ffsll.c standard libkern/flsll.c standard libkern/memcmp.c standard libkern/memset.c standard libkern/moddi3.c standard libkern/qdivrem.c standard libkern/ucmpdi2.c standard libkern/udivdi3.c standard libkern/umoddi3.c standard # # x86 real mode BIOS support, required by dpms/pci/vesa # compat/x86bios/x86bios.c optional x86bios | dpms | pci | vesa # # bvm console # dev/bvm/bvm_console.c optional bvmconsole dev/bvm/bvm_dbg.c optional bvmdebug # Common files where we currently configure the system differently, but perhaps shouldn't # config(8) doesn't have a way to force standard options, so we've been inconsistent # about marking non-optional things 'standard'. x86/acpica/madt.c optional acpi apic x86/cpufreq/smist.c optional cpufreq x86/isa/atpic.c optional atpic x86/isa/elcr.c optional atpic | apic x86/isa/isa.c optional isa x86/isa/isa_dma.c optional isa x86/x86/io_apic.c optional apic x86/x86/local_apic.c optional apic x86/x86/mptable.c optional apic x86/x86/mptable_pci.c optional apic pci x86/x86/msi.c optional apic pci Index: head/sys/dev/ntb/test/ntb_tool.c =================================================================== --- head/sys/dev/ntb/test/ntb_tool.c (nonexistent) +++ head/sys/dev/ntb/test/ntb_tool.c (revision 351137) @@ -0,0 +1,1516 @@ +/*- + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright (c) 2019 Advanced Micro Devices, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * BSD LICENSE + * + * Copyright (c) 2019 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copy + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Advanced Micro Devices, Inc nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * PCIe NTB Debugging Tool FreeBSD driver + */ + +/* + * How to use this tool, by example. + * + * List of sysctl for ntb_tool driver. + * root@local# sysctl -a | grep ntb_tool + * dev.ntb_tool.0.peer0.spad7: 0x0 + * dev.ntb_tool.0.peer0.spad6: 0x0 + * dev.ntb_tool.0.peer0.spad5: 0x0 + * dev.ntb_tool.0.peer0.spad4: 0x0 + * dev.ntb_tool.0.peer0.spad3: 0x0 + * dev.ntb_tool.0.peer0.spad2: 0x0 + * dev.ntb_tool.0.peer0.spad1: 0x0 + * dev.ntb_tool.0.peer0.spad0: 0x0 + * dev.ntb_tool.0.peer0.mw_trans2: + * dev.ntb_tool.0.peer0.mw_trans1: + * dev.ntb_tool.0.peer0.mw_trans0: + * dev.ntb_tool.0.peer0.peer_mw2: + * dev.ntb_tool.0.peer0.peer_mw1: + * dev.ntb_tool.0.peer0.peer_mw0: + * dev.ntb_tool.0.peer0.mw2: + * dev.ntb_tool.0.peer0.mw1: + * dev.ntb_tool.0.peer0.mw0: + * dev.ntb_tool.0.peer0.link_event: 0x0 + * dev.ntb_tool.0.peer0.link: Y + * dev.ntb_tool.0.peer0.port: 1 + * dev.ntb_tool.0.spad7: 0x0 + * dev.ntb_tool.0.spad6: 0x0 + * dev.ntb_tool.0.spad5: 0x0 + * dev.ntb_tool.0.spad4: 0x0 + * dev.ntb_tool.0.spad3: 0x0 + * dev.ntb_tool.0.spad2: 0x0 + * dev.ntb_tool.0.spad1: 0x0 + * dev.ntb_tool.0.spad0: 0x0 + * dev.ntb_tool.0.db: 0x0 + * dev.ntb_tool.0.db_event: 0x0 + * dev.ntb_tool.0.db_mask: 0xffff + * dev.ntb_tool.0.db_valid_mask: 0xffff + * dev.ntb_tool.0.peer_db: 0x0 + * dev.ntb_tool.0.peer_db_mask: 0xffff + * dev.ntb_tool.0.link: Y + * dev.ntb_tool.0.port: 0 + * + * The above example list shows + * 1) three memory windows, + * 1) eight scratchpad registers. + * 3) doorbell config. + * 4) link config. + * 2) One peer. + * + * Based on the underlined ntb_hw driver config & connection topology, these + * things might differ. + *----------------------------------------------------------------------------- + * Eg: check local/peer port information. + * + * # Get local device port number + * root@local# sysctl dev.ntb_tool.0.port + * + * # Check peer device port number + * root@local# sysctl dev.ntb_tool.0.peer0.port + *----------------------------------------------------------------------------- + * Eg: NTB link tests + * + * # Set local link up/down + * root@local# sysctl dev.ntb_tool.0.link=Y + * root@local# sysctl dev.ntb_tool.0.link=N + * + * # Check if link with peer device is up/down: + * root@local# sysctl dev.ntb_tool.0.peer0.link + * + * # Poll until the link specified as up/down. For up, value needs to be set + * depends on peer index, i.e., for peer0 it is 0x1 and for down, value needs + * to be set as 0x0. + * root@local# sysctl dev.ntb_tool.0.peer0.link_event=0x1 + * root@local# sysctl dev.ntb_tool.0.peer0.link_event=0x0 + *----------------------------------------------------------------------------- + * Eg: Doorbell registers tests + * + * # clear/get local doorbell + * root@local# sysctl dev.ntb_tool.0.db="c 0x1" + * root@local# sysctl dev.ntb_tool.0.db + * + * # Set/clear/get local doorbell mask + * root@local# sysctl dev.ntb_tool.0.db_mask="s 0x1" + * root@local# sysctl dev.ntb_tool.0.db_mask="c 0x1" + * root@local# sysctl dev.ntb_tool.0.db_mask + * + * # Ring/clear/get peer doorbell + * root@local# sysctl dev.ntb_tool.0.peer_db="s 0x1" + * root@local# sysctl dev.ntb_tool.0.peer_db="c 0x1" + * root@local# sysctl dev.ntb_tool.0.peer_db + * + * # Set/clear/get peer doorbell mask (functionality is absent) + * root@local# sysctl dev.ntb_tool.0.peer_db_mask="s 0x1" + * root@local# sysctl dev.ntb_tool.0.peer_db_mask="c 0x1" + * root@local# sysctl dev.ntb_tool.0.peer_db_mask + * + * # Poll until local doorbell is set with the specified db bits + * root@local# dev.ntb_tool.0.db_event=0x1 + *----------------------------------------------------------------------------- + * Eg: Scratchpad registers tests + * + * # Write/read to/from local scratchpad register #0 + * root@local# sysctl dev.ntb_tool.0.spad0=0x1023457 + * root@local# sysctl dev.ntb_tool.0.spad0 + * + * # Write/read to/from peer scratchpad register #0 + * root@local# sysctl dev.ntb_tool.0.peer0.spad0=0x01020304 + * root@local# sysctl dev.ntb_tool.0.peer0.spad0 + *----------------------------------------------------------------------------- + * Eg: Memory windows tests (need to configure local mw_trans on both sides) + * + * # Create inbound memory window buffer of specified size/get its dma address + * root@local# sysctl dev.ntb_tool.0.peer0.mw_trans0=16384 + * root@local# sysctl dev.ntb_tool.0.peer0.mw_trans0 + * + * # Write/read data to/from inbound memory window with specific pattern/random + * data. + * root@local# sysctl dev.ntb_tool.0.peer0.mw0="W offset 0 nbytes 100 pattern ab" + * root@local# sysctl dev.ntb_tool.0.peer0.mw0="R offset 0 nbytes 100" + * + * # Write/read data to/from outbound memory window on the local device with + * specific pattern/random (on peer device) + * root@local# sysctl dev.ntb_tool.0.peer0.peer_mw0="W offset 0 nbytes 100 pattern ab" + * root@local# sysctl dev.ntb_tool.0.peer0.peer_mw0="R offset 0 nbytes 100" + *----------------------------------------------------------------------------- + * NOTE: *Message registers are not supported* + *----------------------------------------------------------------------------- + * + * contact information: + * Arpan Palit + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "../ntb.h" + +/* Buffer length for User input */ +#define TOOL_BUF_LEN 48 +/* Memory window default command read and write offset. */ +#define DEFAULT_MW_OFF 0 +/* Memory window default size and also max command read size. */ +#define DEFAULT_MW_SIZE 1024 + +MALLOC_DEFINE(M_NTB_TOOL, "ntb_tool", "ntb_tool driver memory allocation"); + +/* + * Memory windows descriptor structure + */ +struct tool_mw { + struct tool_ctx *tc; + int widx; + int pidx; + + /* Rx buff is off virt_addr / dma_base */ + bus_addr_t dma_base; + caddr_t virt_addr; + bus_dmamap_t dma_map; + bus_dma_tag_t dma_tag; + + /* Tx buff is off vbase / phys_addr */ + caddr_t mm_base; + vm_paddr_t phys_addr; + bus_addr_t addr_limit; + size_t phys_size; + size_t xlat_align; + size_t xlat_align_size; + + /* Memory window configured size and limits */ + size_t size; + ssize_t mw_buf_size; + ssize_t mw_buf_offset; + ssize_t mw_peer_buf_size; + ssize_t mw_peer_buf_offset; + + /* options to handle sysctl out */ + int mw_cmd_rw; + int mw_peer_cmd_rw; +}; + +struct tool_spad { + int sidx; + int pidx; + struct tool_ctx *tc; +}; + +struct tool_peer { + int pidx; + struct tool_ctx *tc; + int inmw_cnt; + struct tool_mw *inmws; + int outspad_cnt; + struct tool_spad *outspads; + unsigned int port_no; +}; + +struct tool_ctx { + device_t dev; + struct callout link_event_timer; + struct callout db_event_timer; + int peer_cnt; + struct tool_peer *peers; + int inmsg_cnt; + struct tool_msg *inmsgs; + int inspad_cnt; + struct tool_spad *inspads; + unsigned int unsafe; + + /* sysctl read out variables */ + char link_status; + uint64_t link_bits; + uint64_t link_mask; + uint64_t db_valid_mask; + uint64_t db_mask_val; + uint64_t db_event_val; + uint64_t peer_db_val; + uint64_t peer_db_mask_val; + unsigned int port_no; +}; + +/* structure to save dma_addr after dma load */ +struct ntb_tool_load_cb_args { + bus_addr_t addr; + int error; +}; + +/* + * NTB events handlers + */ +static void +tool_link_event(void *ctx) +{ + struct tool_ctx *tc = ctx; + enum ntb_speed speed = 0; + enum ntb_width width = 0; + int up = 0; + + up = ntb_link_is_up(tc->dev, &speed, &width); + if (up) + tc->link_status = 'Y'; + else + tc->link_status = 'N'; + + device_printf(tc->dev, "link is %s speed %d width %d\n", + up ? "up" : "down", speed, width); +} + +static void +tool_db_event(void *ctx, uint32_t vec) +{ + struct tool_ctx *tc = ctx; + uint64_t db_bits, db_mask; + + db_mask = ntb_db_vector_mask(tc->dev, vec); + db_bits = ntb_db_read(tc->dev); + + device_printf(tc->dev, "doorbell vec %d mask %#llx bits %#llx\n", + vec, (unsigned long long)db_mask, (unsigned long long)db_bits); +} + +static const struct ntb_ctx_ops tool_ops = { + .link_event = tool_link_event, + .db_event = tool_db_event, +}; + +/* + * Callout event methods + */ +static void +tool_link_event_handler(void *arg) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg; + uint64_t val; + + val = ntb_link_is_up(tc->dev, NULL, NULL) & tc->link_mask; + + if (val == tc->link_bits) { + device_printf(tc->dev, "link_event successful for link val=" + "0x%jx\n", tc->link_bits); + tc->link_bits = 0x0; + tc->link_mask = 0x0; + } else + callout_reset(&tc->link_event_timer, 1, tool_link_event_handler, tc); +} + +static void +tool_db_event_handler(void *arg) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg; + uint64_t db_bits; + + db_bits = ntb_db_read(tc->dev); + + if (db_bits == tc->db_event_val) { + device_printf(tc->dev, "db_event successful for db val=0x%jx\n", + tc->db_event_val); + tc->db_event_val = 0x0; + } else + callout_reset(&tc->db_event_timer, 1, tool_db_event_handler, tc); +} + +/* + * Common read/write methods + */ +static inline int +get_ubuf(struct sysctl_req *req, char *ubuf) +{ + int rc; + + if (req->newlen >= TOOL_BUF_LEN) + return (EINVAL); + + rc = SYSCTL_IN(req, ubuf, req->newlen); + if (rc) + return (rc); + ubuf[req->newlen] = '\0'; + + return (0); +} + +static int +read_out(struct sysctl_req *req, uint64_t val) +{ + char ubuf[16]; + + memset((void *)ubuf, 0, sizeof(ubuf)); + snprintf(ubuf, sizeof(ubuf), "0x%jx", val); + + return SYSCTL_OUT(req, ubuf, sizeof(ubuf)); +} + +static int +tool_fn_read(struct tool_ctx *tc, struct sysctl_req *req, + uint64_t (*fn_read)(device_t ), uint64_t val) +{ + if (fn_read == NULL) + return read_out(req, val); + else if (fn_read) + return read_out(req, (uint64_t)fn_read(tc->dev)); + else + return (EINVAL); +} + +static int +tool_fn_write(struct tool_ctx *tc, struct sysctl_oid *oidp, + struct sysctl_req *req, char *ubuf, uint64_t *val, bool db_mask_sflag, + void (*fn_set)(device_t , uint64_t), void (*fn_clear)(device_t , uint64_t)) +{ + uint64_t db_valid_mask = tc->db_valid_mask; + uint64_t bits; + char cmd; + + if (fn_set == NULL && fn_clear == NULL) { + device_printf(tc->dev, "ERR: Set & Clear both are not supported\n"); + return (EINVAL); + } + + if (tc->db_valid_mask == 0) + db_valid_mask = tc->db_valid_mask = ntb_db_valid_mask(tc->dev); + + bits = 0; + sscanf(ubuf, "%c %jx", &cmd, &bits); + if (cmd == 's') { + if ((bits | db_valid_mask) > db_valid_mask) { + device_printf(tc->dev, "0x%jx value is not supported\n", bits); + return (EINVAL); + } + if (fn_set) + fn_set(tc->dev, bits); + else + return (EINVAL); + if (val) + *val |= bits; + } else if (cmd == 'c') { + if ((bits | db_valid_mask) > db_valid_mask) { + device_printf(tc->dev, "0x%jx value is not supported\n", bits); + return (EINVAL); + } + if (fn_clear) + fn_clear(tc->dev, bits); + if (val) + *val &= ~bits; + } else { + device_printf(tc->dev, "Wrong Write\n"); + return (EINVAL); + } + + return (0); +} + +static int +parse_mw_buf(char *buf, char *cmd, ssize_t *offset, ssize_t *buf_size, + uint64_t *pattern, bool *s_pflag) +{ + char op1[8], op2[8], op3[8]; + uint64_t val1, val2, val3; + bool vs1, vs2, vs3; + int rc = 0; + + vs1 = vs2 = vs3 = false; + sscanf(buf, "%c %s %jx %s %jx %s %jx", + cmd, op1, &val1, op2, &val2, op3, &val3); + + if (*cmd != 'W' && *cmd != 'R') + return (EINVAL); + + if (!strcmp(op1, "offset")) { + *offset = val1 ? val1 : DEFAULT_MW_OFF; + vs1 = true; + } else if (!strcmp(op1, "nbytes")) { + *buf_size = val1 ? val1: DEFAULT_MW_SIZE; + vs2 = true; + } else if (!strcmp(op1, "pattern")) { + *pattern = val1; + vs3 = true; + } + + if (!vs1 && !strcmp(op2, "offset")) { + *offset = val2 ? val2 : DEFAULT_MW_OFF; + vs1 = true; + } else if (!vs2 && !strcmp(op2, "nbytes")) { + *buf_size = val2 ? val2: DEFAULT_MW_SIZE; + vs2 = true; + } else if (!vs3 && !strcmp(op2, "pattern")) { + *pattern = val2; + vs3 = true; + } + + if (!vs1 && !strcmp(op3, "offset")) { + *offset = val3 ? val3 : DEFAULT_MW_OFF; + } else if (!vs2 && !strcmp(op3, "nbytes")) { + *buf_size = val3 ? val3: DEFAULT_MW_SIZE; + } else if (!vs3 && !strcmp(op3, "pattern")) { + *pattern = val3; + vs3 = true; + } + + *s_pflag = vs3; + if (vs3 && *cmd == 'R') + printf("NTB_TOOL_WARN: pattern is not supported with read " + "command\n"); + + return (rc); +} + +static int +tool_mw_read_fn(struct sysctl_req *req, struct tool_mw *inmw, char *read_addr, + int *cmd_op, ssize_t buf_off, ssize_t buf_size, char *type) +{ + ssize_t index, size; + struct sbuf *sb; + int i, loop, rc; + char *tmp; + + /* The below check is made to ignore sysctl read call. */ + if (*cmd_op == 0) + return (0); + + /* Proceeds only when command R/W is requested using sysctl. */ + index = buf_off; + tmp = read_addr; + tmp += index; + loop = ((buf_size == 0) || (buf_size > DEFAULT_MW_SIZE)) ? + DEFAULT_MW_SIZE : buf_size; + /* + * 256 bytes of extra buffer has been allocated to print details like + * summary, size, notes, i.e., excluding data part. + */ + size = loop + 256; + sb = sbuf_new_for_sysctl(NULL, NULL, size, req); + if (sb == NULL) { + rc = sb->s_error; + return (rc); + } + + if (!strcmp(type, "mw")) + sbuf_printf(sb, "\nConfigured MW size\t: %zu\n", inmw->size); + else if (!strcmp(type, "peer_mw")) + sbuf_printf(sb, "\nConfigured Peer MW size\t: %zu\n", + inmw->size); + sbuf_printf(sb, "R/W size\t\t: %zi\nR/W Offset\t\t: %zi\n\nData\n----" + "->", buf_size, buf_off); + + /* + * Data will be read based on MW size provided by the user using nbytes, + * which is limited to 1024 bytes if user req bigger size to read, check + * above loop calculation which is limiting or setting the MW read size. + * Below for loop prints data where in each line contains 32 bytes data + * and after each 8 bytes of data we used four spaces which ensures one + * data block. + */ + for (i = 0 ; i < loop; i++) { + if ((i % 32) == 0) { + sbuf_printf(sb, "\n%08zx:", index); + index += 32; + } + if ((i % 8) == 0) + sbuf_printf(sb, " "); + sbuf_printf(sb, "%02hhx", *(tmp+i)); + } + if (buf_size > DEFAULT_MW_SIZE) + sbuf_printf(sb, "\n\nNOTE: Truncating read size %zi->1024 " + "bytes\n", buf_size); + + /* cmd_op is set to zero after completion of each R/W command. */ + *cmd_op -= 1; + rc = sbuf_finish(sb); + sbuf_delete(sb); + + return (rc); +} + +static int +tool_mw_write_fn(struct sysctl_oid *oidp, struct sysctl_req *req, + struct tool_mw *inmw, char *ubuf, caddr_t write_buf, int *cmd_op, + ssize_t *buf_offset, ssize_t *buf_size) +{ + ssize_t data_buf_size; + uint64_t pattern = 0; + bool s_pflag = false; + void *data_buf; + char cmd; + int rc; + + if (!write_buf) + return (ENXIO); + + /* buf_offset and buf_size set to default in case user does not req */ + *buf_offset = DEFAULT_MW_OFF; + *buf_size = DEFAULT_MW_SIZE; + rc = parse_mw_buf(ubuf, &cmd, buf_offset, buf_size, &pattern, &s_pflag); + if (rc) { + device_printf(inmw->tc->dev, "Wrong Command \"%c\" provided\n", + cmd); + return (rc); + } + + /* Check for req size and buffer limit */ + if ((*buf_offset + *buf_size) > inmw->size) { + device_printf(inmw->tc->dev, "%s: configured mw size :%zi and " + "requested size :%zi.\n", __func__, inmw->size, + (*buf_offset + *buf_size)); + *buf_offset = DEFAULT_MW_OFF; + *buf_size = DEFAULT_MW_SIZE; + rc = EINVAL; + goto out; + } + + if (cmd == 'R') + goto read_out; + else if (cmd == 'W') + goto write; + else + goto out; + +write: + data_buf_size = *buf_size; + data_buf = malloc(data_buf_size, M_NTB_TOOL, M_WAITOK | M_ZERO); + if (!data_buf) { + rc = ENOMEM; + goto out; + } + + if (s_pflag) + memset(data_buf, pattern, data_buf_size); + else + arc4rand(data_buf, data_buf_size, 1); + + memcpy(write_buf + *buf_offset, data_buf, data_buf_size); + + free(data_buf, M_NTB_TOOL); + +read_out: + /* cmd_op value is set to two as sysctl read call executes twice */ + *cmd_op = 2; +out: + return (rc); +} + +/* + * Port sysctl read/write methods + */ +static int +sysctl_peer_port_number(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + int rc, pidx = arg2, peer_port; + + peer_port = ntb_peer_port_number(tc->dev, pidx); + rc = sysctl_handle_int(oidp, &peer_port, 0, req); + if (rc) + device_printf(tc->dev, "Peer port sysctl set failed with err=" + "(%d).\n", rc); + else + tc->peers[pidx].port_no = peer_port; + + return (rc); +} + +static int +sysctl_local_port_number(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + int rc, local_port; + + local_port = ntb_port_number(tc->dev); + rc = sysctl_handle_int(oidp, &local_port, 0, req); + if (rc) + device_printf(tc->dev, "Local port sysctl set failed with err=" + "(%d).\n", rc); + else + tc->port_no = local_port; + + return (rc); +} + +static int +tool_init_peers(struct tool_ctx *tc) +{ + int pidx; + + tc->peer_cnt = ntb_peer_port_count(tc->dev); + tc->peers = malloc(tc->peer_cnt * sizeof(*tc->peers), M_NTB_TOOL, + M_WAITOK | M_ZERO); + if (tc->peers == NULL) + return (ENOMEM); + for (pidx = 0; pidx < tc->peer_cnt; pidx++) { + tc->peers[pidx].pidx = pidx; + tc->peers[pidx].tc = tc; + } + + return (0); +} + +static void +tool_clear_peers(struct tool_ctx *tc) +{ + + free(tc->peers, M_NTB_TOOL); +} + +/* + * Link state sysctl read/write methods + */ +static int +sysctl_link_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + char buf[TOOL_BUF_LEN]; + int rc; + + if (req->newptr == NULL) { + snprintf(buf, 2, "%c", tc->link_status); + + return SYSCTL_OUT(req, buf, 2); + } + + rc = get_ubuf(req, buf); + if (rc) + return (rc); + + if (buf[0] == 'Y') + rc = ntb_link_enable(tc->dev, NTB_SPEED_AUTO, NTB_WIDTH_AUTO); + else if (buf[0] == 'N') + rc = ntb_link_disable(tc->dev); + else + rc = EINVAL; + + sscanf(buf, "%c", &tc->link_status); + + return (0); +} + +static int +sysctl_peer_link_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + int up = 0, pidx = arg2; + char buf[TOOL_BUF_LEN]; + + if (req->newptr) + return (0); + + up = ntb_link_is_up(tc->dev, NULL, NULL); + memset((void *)buf, 0, TOOL_BUF_LEN); + if (up & (1UL << pidx)) + buf[0] = 'Y'; + else + buf[0] = 'N'; + + return SYSCTL_OUT(req, buf, sizeof(buf)); +} + +static int +sysctl_peer_link_event_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + char buf[TOOL_BUF_LEN]; + int rc, pidx = arg2; + uint64_t bits; + + if (req->newptr == NULL) + return read_out(req, tc->link_bits); + + rc = get_ubuf(req, buf); + if (rc) + return (rc); + + sscanf(buf, "0x%jx", &bits); + tc->link_bits = bits; + tc->link_mask = (1ULL << ((pidx) % 64)); + + callout_reset(&tc->link_event_timer, 1, tool_link_event_handler, tc); + return (0); +} + +/* + * Memory windows read/write/setting methods + */ +static void +ntb_tool_load_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + struct ntb_tool_load_cb_args *cba = (struct ntb_tool_load_cb_args *)arg; + + if (!(cba->error = error)) + cba->addr = segs[0].ds_addr; +} + +static int +sysctl_mw_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_mw *inmw = (struct tool_mw *)arg1; + char buf[TOOL_BUF_LEN]; + int rc; + + if (req->newptr == NULL) + return tool_mw_read_fn(req, inmw, (char *)inmw->mm_base, + &inmw->mw_cmd_rw, inmw->mw_buf_offset, inmw->mw_buf_size, + "mw"); + + rc = get_ubuf(req, buf); + if (!rc) + return tool_mw_write_fn(oidp, req, inmw, buf, inmw->mm_base, + &inmw->mw_cmd_rw, &inmw->mw_buf_offset, &inmw->mw_buf_size); + + return (rc); +} + +static int +tool_setup_mw(struct tool_ctx *tc, unsigned int pidx, unsigned int widx, + size_t req_size) +{ + struct tool_mw *inmw = &tc->peers[pidx].inmws[widx]; + struct ntb_tool_load_cb_args cba; + int rc; + + if (req_size == 0) + inmw->size = roundup(inmw->phys_size, inmw->xlat_align_size); + else + inmw->size = roundup(req_size, inmw->xlat_align_size); + + device_printf(tc->dev, "mw_size %zi req_size %zi buff %zi\n", + inmw->phys_size, req_size, inmw->size); + + if (bus_dma_tag_create(bus_get_dma_tag(tc->dev), inmw->xlat_align, 0, + inmw->addr_limit, BUS_SPACE_MAXADDR, NULL, NULL, inmw->size, 1, + inmw->size, 0, NULL, NULL, &inmw->dma_tag)) { + device_printf(tc->dev, "Unable to create MW tag of size " + "%zu/%zu\n", inmw->phys_size, inmw->size); + rc = ENOMEM; + goto err_free_dma_var; + } + + if (bus_dmamem_alloc(inmw->dma_tag, (void **)&inmw->virt_addr, + BUS_DMA_WAITOK | BUS_DMA_ZERO, &inmw->dma_map)) { + device_printf(tc->dev, "Unable to allocate MW buffer of size " + "%zu/%zu\n", inmw->phys_size, inmw->size); + rc = ENOMEM; + goto err_free_tag_rem; + } + + if (bus_dmamap_load(inmw->dma_tag, inmw->dma_map, inmw->virt_addr, + inmw->size, ntb_tool_load_cb, &cba, BUS_DMA_NOWAIT) || cba.error) { + device_printf(tc->dev, "Unable to load MW buffer of size " + "%zu/%zu\n", inmw->phys_size, inmw->size); + rc = ENOMEM; + goto err_free_dma; + } + inmw->dma_base = cba.addr; + + rc = ntb_mw_set_trans(tc->dev, widx, inmw->dma_base, inmw->size); + if (rc) + goto err_free_mw; + + return (0); + +err_free_mw: + bus_dmamap_unload(inmw->dma_tag, inmw->dma_map); + +err_free_dma: + bus_dmamem_free(inmw->dma_tag, inmw->virt_addr, inmw->dma_map); + +err_free_tag_rem: + bus_dma_tag_destroy(inmw->dma_tag); + +err_free_dma_var: + inmw->size = 0; + inmw->virt_addr = 0; + inmw->dma_base = 0; + inmw->dma_tag = 0; + inmw->dma_map = 0; + + return (rc); +} + +static void +tool_free_mw(struct tool_ctx *tc, int pidx, int widx) +{ + struct tool_mw *inmw = &tc->peers[pidx].inmws[widx]; + + if (inmw->dma_base) + ntb_mw_clear_trans(tc->dev, widx); + + if (inmw->virt_addr && inmw->dma_tag) { + bus_dmamap_unload(inmw->dma_tag, inmw->dma_map); + bus_dmamem_free(inmw->dma_tag, inmw->virt_addr, inmw->dma_map); + bus_dma_tag_destroy(inmw->dma_tag); + } + + inmw->virt_addr = 0; + inmw->dma_base = 0; + inmw->dma_tag = 0; + inmw->dma_map = 0; + inmw->mm_base = 0; + inmw->size = 0; +} + +static int +tool_mw_trans_read(struct tool_mw *inmw, struct sysctl_req *req) +{ + ssize_t buf_size = 512; + struct sbuf *sb; + int rc = 0; + + sb = sbuf_new_for_sysctl(NULL, NULL, buf_size, req); + if (sb == NULL) { + rc = sb->s_error; + return (rc); + } + + sbuf_printf(sb, "\nInbound MW \t%d\n", inmw->widx); + sbuf_printf(sb, "Port \t%d (%d)\n", + ntb_peer_port_number(inmw->tc->dev, inmw->pidx), inmw->pidx); + sbuf_printf(sb, "Window Address \t%p\n", inmw->mm_base); + sbuf_printf(sb, "DMA Address \t0x%016llx\n", (long long)inmw->dma_base); + sbuf_printf(sb, "Window Size \t0x%016zx[p]\n", inmw->size); + sbuf_printf(sb, "Alignment \t0x%016zx[p]\n", inmw->xlat_align); + sbuf_printf(sb, "Size Alignment \t0x%016zx[p]\n", + inmw->xlat_align_size); + sbuf_printf(sb, "Size Max \t0x%016zx[p]\n", inmw->phys_size); + + rc = sbuf_finish(sb); + sbuf_delete(sb); + + return (rc); +} + +static int +tool_mw_trans_write(struct sysctl_oid *oidp, struct sysctl_req *req, + struct tool_mw *inmw, size_t wsize) +{ + struct tool_ctx *tc = inmw->tc; + int rc = 0; + + if (wsize == 0) + return (EINVAL); + + /* No need to re-setup mw */ + if (inmw->size == wsize) + return (0); + + /* free mw dma buffer */ + if (inmw->size) + tool_free_mw(tc, inmw->pidx, inmw->widx); + + rc = tool_setup_mw(tc, inmw->pidx, inmw->widx, wsize); + + return (rc); +} + +static int +sysctl_mw_trans_handler(SYSCTL_HANDLER_ARGS) +{ + struct tool_mw *inmw = (struct tool_mw *)arg1; + char buf[TOOL_BUF_LEN]; + ssize_t wsize; + int rc; + + if (req->newptr == NULL) + return tool_mw_trans_read(inmw, req); + + rc = get_ubuf(req, buf); + if (rc == 0) { + sscanf(buf, "%zi", &wsize); + return tool_mw_trans_write(oidp, req, inmw, wsize); + } + + return (rc); +} + +static int +sysctl_peer_mw_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_mw *inmw = (struct tool_mw *)arg1; + char buf[TOOL_BUF_LEN]; + int rc; + + if (req->newptr == NULL) + return tool_mw_read_fn(req, inmw, (char *)inmw->virt_addr, + &inmw->mw_peer_cmd_rw, inmw->mw_peer_buf_offset, + inmw->mw_peer_buf_size, "mw"); + + rc = get_ubuf(req, buf); + if (rc == 0) + return tool_mw_write_fn(oidp, req, inmw, buf, inmw->virt_addr, + &inmw->mw_peer_cmd_rw, &inmw->mw_peer_buf_offset, + &inmw->mw_peer_buf_size); + + return (rc); +} + +static void tool_clear_mws(struct tool_ctx *tc) +{ + int widx, pidx; + + /* Free outbound memory windows */ + for (pidx = 0; pidx < tc->peer_cnt; pidx++) { + for (widx = 0; widx < tc->peers[pidx].inmw_cnt; widx++) + tool_free_mw(tc, pidx, widx); + free(tc->peers[pidx].inmws, M_NTB_TOOL); + } +} + +static int +tool_init_mws(struct tool_ctx *tc) +{ + struct tool_mw *mw; + int widx, pidx, rc; + + /* Initialize inbound memory windows and outbound MWs wrapper */ + for (pidx = 0; pidx < tc->peer_cnt; pidx++) { + tc->peers[pidx].inmw_cnt = ntb_mw_count(tc->dev); + tc->peers[pidx].inmws = malloc(tc->peers[pidx].inmw_cnt * + sizeof(*tc->peers[pidx].inmws), M_NTB_TOOL, + M_WAITOK | M_ZERO); + if (tc->peers[pidx].inmws == NULL) + return (ENOMEM); + + for (widx = 0; widx < tc->peers[pidx].inmw_cnt; widx++) { + mw = &tc->peers[pidx].inmws[widx]; + memset((void *)mw, 0, sizeof(*mw)); + mw->tc = tc; + mw->widx = widx; + mw->pidx = pidx; + mw->mw_buf_offset = DEFAULT_MW_OFF; + mw->mw_buf_size = DEFAULT_MW_SIZE; + /* get the tx buff details for each mw attached with each peer */ + rc = ntb_mw_get_range(tc->dev, widx, &mw->phys_addr, + &mw->mm_base, &mw->phys_size, &mw->xlat_align, + &mw->xlat_align_size, &mw->addr_limit); + if (rc) + goto free_mws; + } + } + + return (0); + +free_mws: + tool_clear_mws(tc); + return (rc); +} + +/* + * Doorbell handler for read/write + */ +static int +sysctl_db_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + char buf[TOOL_BUF_LEN]; + uint64_t db_bits; + int rc; + + if (req->newptr == NULL) { + db_bits = ntb_db_read(tc->dev); + return read_out(req, db_bits); + } + + rc = get_ubuf(req, buf); + if (rc == 0) + return tool_fn_write(tc, oidp, req, buf, NULL, false, NULL, + ntb_db_clear); + + return (rc); +} + +static int +sysctl_db_valid_mask_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + + tc->db_valid_mask = ntb_db_valid_mask(tc->dev); + if (!tc->db_valid_mask) { + device_printf(tc->dev, "Error getting db_valid_mask from " + "hw driver\n"); + return (EINVAL); + } else { + return read_out(req, tc->db_valid_mask); + } +} + +static int +sysctl_db_mask_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + char buf[TOOL_BUF_LEN]; + int rc; + + if (req->newptr == NULL) { + if (tc->db_mask_val == 0) + ntb_db_valid_mask(tc->dev); + return tool_fn_read(tc, req, NULL, tc->db_mask_val); + } + + rc = get_ubuf(req, buf); + if (rc == 0) + return tool_fn_write(tc, oidp, req, buf, &tc->db_mask_val, true, + ntb_db_set_mask, ntb_db_clear_mask); + + return (rc); +} + +static int +sysctl_peer_db_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + char buf[TOOL_BUF_LEN]; + int rc; + + if (req->newptr == NULL) + return tool_fn_read(tc, req, NULL, tc->peer_db_val); + + rc = get_ubuf(req, buf); + if (rc == 0) + return tool_fn_write(tc, oidp, req, buf, &tc->peer_db_val, + false, ntb_peer_db_set, NULL); + + return (rc); +} + +static int +sysctl_peer_db_mask_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + char buf[TOOL_BUF_LEN]; + int rc; + + if (req->newptr == NULL){ + if (tc->peer_db_mask_val == 0) + ntb_db_valid_mask(tc->dev); + return tool_fn_read(tc, req, NULL, tc->peer_db_mask_val); + } + + rc = get_ubuf(req, buf); + if (rc == 0) + return tool_fn_write(tc, oidp, req, buf, &tc->peer_db_mask_val, + true, NULL, NULL); + + return (rc); +} + +static int +sysctl_db_event_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + char buf[TOOL_BUF_LEN]; + uint64_t bits; + int rc; + + if (req->newptr == NULL) + return read_out(req, tc->db_event_val); + + rc = get_ubuf(req, buf); + if (rc) + return (rc); + + sscanf(buf, "%ju", &bits); + tc->db_event_val = bits; + callout_reset(&tc->db_event_timer, 1, tool_db_event_handler, tc); + + return (0); +} + +/* + * Scratchpads read/write methods + */ +static int +sysctl_spad_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + unsigned int sidx = arg2; + char buf[TOOL_BUF_LEN]; + uint32_t bits; + int rc; + + if (req->newptr == NULL) { + rc = ntb_spad_read(tc->dev, sidx, &bits); + if (rc) + return (rc); + else + return read_out(req, (uint64_t )bits); + } + + rc = get_ubuf(req, buf); + if (rc == 0) { + sscanf(buf, "%i", &bits); + return ntb_spad_write(tc->dev, sidx, bits); + } + + return (rc); +} + +static int +sysctl_peer_spad_handle(SYSCTL_HANDLER_ARGS) +{ + struct tool_ctx *tc = (struct tool_ctx *)arg1; + unsigned int sidx = arg2; + char buf[TOOL_BUF_LEN]; + uint32_t bits; + int rc; + + if (req->newptr == NULL) { + rc = ntb_peer_spad_read(tc->dev, sidx, &bits); + if (rc) + return (rc); + else + return read_out(req, (uint64_t )bits); + } + + rc = get_ubuf(req, buf); + if (rc == 0) { + sscanf(buf, "%i", &bits); + return ntb_peer_spad_write(tc->dev, sidx, bits); + } + + return (rc); +} + +static int +tool_init_spads(struct tool_ctx *tc) +{ + int sidx, pidx; + + /* Initialize inbound scratchpad structures */ + tc->inspad_cnt = ntb_spad_count(tc->dev); + tc->inspads = malloc(tc->inspad_cnt * sizeof(*tc->inspads), M_NTB_TOOL, + M_WAITOK | M_ZERO); + if (tc->inspads == NULL) + return (ENOMEM); + + for (sidx = 0; sidx < tc->inspad_cnt; sidx++) { + tc->inspads[sidx].sidx = sidx; + tc->inspads[sidx].pidx = -1; + tc->inspads[sidx].tc = tc; + } + + /* Initialize outbound scratchpad structures */ + for (pidx = 0; pidx < tc->peer_cnt; pidx++) { + tc->peers[pidx].outspad_cnt = ntb_spad_count(tc->dev); + tc->peers[pidx].outspads = malloc(tc->peers[pidx].outspad_cnt * + sizeof(*tc->peers[pidx].outspads), M_NTB_TOOL, M_WAITOK | + M_ZERO); + if (tc->peers[pidx].outspads == NULL) + return (ENOMEM); + + for (sidx = 0; sidx < tc->peers[pidx].outspad_cnt; sidx++) { + tc->peers[pidx].outspads[sidx].sidx = sidx; + tc->peers[pidx].outspads[sidx].pidx = pidx; + tc->peers[pidx].outspads[sidx].tc = tc; + } + } + + return (0); +} + +static void +tool_clear_spads(struct tool_ctx *tc) +{ + int pidx; + + /* Free local inspads. */ + free(tc->inspads, M_NTB_TOOL); + + /* Free outspads for each peer. */ + for (pidx = 0; pidx < tc->peer_cnt; pidx++) + free(tc->peers[pidx].outspads, M_NTB_TOOL); +} + +/* + * Initialization methods + */ +static int +tool_check_ntb(struct tool_ctx *tc) +{ + + /* create and initialize link callout handler */ + callout_init(&tc->link_event_timer, 1); + + /* create and initialize db callout handler */ + callout_init(&tc->db_event_timer, 1); + + /* Initialize sysctl read out values to default */ + tc->link_status = 'U'; + tc->db_mask_val = 0; + tc->peer_db_val = 0; + tc->peer_db_mask_val = 0; + tc->db_event_val = 0; + tc->link_bits = 0; + + return (0); +} + +static void +tool_clear_data(struct tool_ctx *tc) +{ + + callout_drain(&tc->link_event_timer); + callout_drain(&tc->db_event_timer); +} + +static int +tool_init_ntb(struct tool_ctx *tc) +{ + + return ntb_set_ctx(tc->dev, tc, &tool_ops); +} + +static void +tool_clear_ntb(struct tool_ctx *tc) +{ + + ntb_clear_ctx(tc->dev); + ntb_link_disable(tc->dev); +} + +/* + * Current sysctl implementation is made such that it gets attached to the + * device and while detach it gets cleared automatically. + */ +static void +tool_setup_sysctl(struct tool_ctx *tc) +{ + char buf[TOOL_BUF_LEN], desc[TOOL_BUF_LEN]; + struct sysctl_oid_list *top, *peer_top; + struct sysctl_oid *parent, *peer; + struct sysctl_ctx_list *clist; + unsigned int pidx, sidx, widx; + + clist = device_get_sysctl_ctx(tc->dev); + parent = device_get_sysctl_tree(tc->dev); + top = SYSCTL_CHILDREN(parent); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "port", CTLTYPE_UINT | + CTLFLAG_RDTUN | CTLFLAG_MPSAFE, tc, 0, sysctl_local_port_number, + "IU", "local port number"); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "link", CTLTYPE_STRING | + CTLFLAG_RWTUN | CTLFLAG_MPSAFE, tc, 0, sysctl_link_handle, + "IU", "link info"); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "db", CTLTYPE_STRING | + CTLFLAG_RWTUN | CTLFLAG_MPSAFE, tc, 0, sysctl_db_handle, + "A", "db info"); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "db_valid_mask", CTLTYPE_STRING | + CTLFLAG_RD | CTLFLAG_MPSAFE, tc, 0, sysctl_db_valid_mask_handle, + "A", "db valid mask"); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "db_mask", CTLTYPE_STRING | + CTLFLAG_RWTUN | CTLFLAG_MPSAFE, tc, 0, sysctl_db_mask_handle, + "A", "db mask"); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "db_event", CTLTYPE_STRING | + CTLFLAG_WR | CTLFLAG_MPSAFE, tc, 0, sysctl_db_event_handle, + "A", "db event"); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "peer_db", CTLTYPE_STRING | + CTLFLAG_RWTUN | CTLFLAG_MPSAFE, tc, 0, sysctl_peer_db_handle, + "A", "peer db"); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, "peer_db_mask", CTLTYPE_STRING | + CTLFLAG_RWTUN | CTLFLAG_MPSAFE, tc, 0, sysctl_peer_db_mask_handle, + "IU", "peer db mask info"); + + if (tc->inspad_cnt != 0) { + for (sidx = 0; sidx < tc->inspad_cnt; sidx++) { + snprintf(buf, sizeof(buf), "spad%d", sidx); + snprintf(desc, sizeof(desc), "spad%d info", sidx); + + SYSCTL_ADD_PROC(clist, top, OID_AUTO, buf, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + tc, sidx, sysctl_spad_handle, "IU", desc); + } + } + + for (pidx = 0; pidx < tc->peer_cnt; pidx++) { + snprintf(buf, sizeof(buf), "peer%d", pidx); + + peer = SYSCTL_ADD_NODE(clist, top, OID_AUTO, buf, CTLFLAG_RW, 0, + buf); + peer_top = SYSCTL_CHILDREN(peer); + + SYSCTL_ADD_PROC(clist, peer_top, OID_AUTO, "port", + CTLTYPE_UINT | CTLFLAG_RDTUN | CTLFLAG_MPSAFE, tc, pidx, + sysctl_peer_port_number, "IU", "peer port number"); + + SYSCTL_ADD_PROC(clist, peer_top, OID_AUTO, "link", + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, tc, pidx, + sysctl_peer_link_handle, "IU", "peer_link info"); + + SYSCTL_ADD_PROC(clist, peer_top, OID_AUTO, "link_event", + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, tc, pidx, + sysctl_peer_link_event_handle, "IU", "link event"); + + for (widx = 0; widx < tc->peers[pidx].inmw_cnt; widx++) { + snprintf(buf, sizeof(buf), "mw_trans%d", widx); + snprintf(desc, sizeof(desc), "mw trans%d info", widx); + + SYSCTL_ADD_PROC(clist, peer_top, OID_AUTO, buf, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + &tc->peers[pidx].inmws[widx], 0, + sysctl_mw_trans_handler, "IU", desc); + + snprintf(buf, sizeof(buf), "mw%d", widx); + snprintf(desc, sizeof(desc), "mw%d info", widx); + + SYSCTL_ADD_PROC(clist, peer_top, OID_AUTO, buf, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + &tc->peers[pidx].inmws[widx], 0, + sysctl_mw_handle, "IU", desc); + + snprintf(buf, sizeof(buf), "peer_mw%d", widx); + snprintf(desc, sizeof(desc), "peer_mw%d info", widx); + + SYSCTL_ADD_PROC(clist, peer_top, OID_AUTO, buf, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + &tc->peers[pidx].inmws[widx], 0, + sysctl_peer_mw_handle, "IU", desc); + } + + for (sidx = 0; sidx < tc->peers[pidx].outspad_cnt; sidx++) { + snprintf(buf, sizeof(buf), "spad%d", sidx); + snprintf(desc, sizeof(desc), "spad%d info", sidx); + + SYSCTL_ADD_PROC(clist, peer_top, OID_AUTO, buf, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, + tc, sidx, sysctl_peer_spad_handle, "IU", desc); + } + } +} + +static int +ntb_tool_probe(device_t dev) +{ + device_set_desc(dev, "NTB TOOL"); + return (0); +} + +static int +ntb_tool_attach(device_t dev) +{ + struct tool_ctx *tc = device_get_softc(dev); + int rc = 0; + + tc->dev = dev; + rc = tool_check_ntb(tc); + if (rc) + goto out; + + rc = tool_init_peers(tc); + if (rc) + goto err_clear_data; + + rc = tool_init_mws(tc); + if (rc) + goto err_clear_data; + + rc = tool_init_spads(tc); + if (rc) + goto err_clear_mws; + + rc = tool_init_ntb(tc); + if (rc) + goto err_clear_spads; + + tool_setup_sysctl(tc); + + return (0); + +err_clear_spads: + tool_clear_spads(tc); +err_clear_mws: + tool_clear_mws(tc); + tool_clear_peers(tc); +err_clear_data: + tool_clear_data(tc); +out: + device_printf(dev, "ntb_tool attached failed with err=(%d).\n", rc); + return (rc); +} + +static int +ntb_tool_detach(device_t dev) +{ + struct tool_ctx *tc = device_get_softc(dev); + + tool_clear_ntb(tc); + + tool_clear_spads(tc); + + tool_clear_mws(tc); + + tool_clear_peers(tc); + + tool_clear_data(tc); + + return (0); +} + +static device_method_t ntb_tool_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ntb_tool_probe), + DEVMETHOD(device_attach, ntb_tool_attach), + DEVMETHOD(device_detach, ntb_tool_detach), + DEVMETHOD_END +}; + +devclass_t ntb_tool_devclass; +static DEFINE_CLASS_0(ntb_tool, ntb_tool_driver, ntb_tool_methods, + sizeof(struct tool_ctx)); +DRIVER_MODULE(ntb_tool, ntb_hw, ntb_tool_driver, ntb_tool_devclass, NULL, NULL); +MODULE_DEPEND(ntb_tool, ntb, 1, 1, 1); +MODULE_VERSION(ntb_tool, 1.0); Property changes on: head/sys/dev/ntb/test/ntb_tool.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sys/modules/ntb/Makefile =================================================================== --- head/sys/modules/ntb/Makefile (revision 351136) +++ head/sys/modules/ntb/Makefile (revision 351137) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= ntb ntb_hw_amd ntb_hw_intel ntb_hw_plx ntb_transport if_ntb +SUBDIR= ntb ntb_hw_amd ntb_hw_intel ntb_hw_plx ntb_transport ntb_tool if_ntb .include