Subject: [patch 02/16] axon driver header files Description: This patch provides include files for the purposes of kernel and userland interfaces into the axon driver. Signed-off-by: H Brett Bolen (hbbolen@us.ibm.com) Signed-off-by: Murali Iyer (mniyer@us.ibm.com) Signed-off-by: Tim Schimke (tschimke@us.ibm.com) Signed-off-by: Jesse Arroyo (arroyoj@us.ibm.com) Index: linux-2.6.23.1/include/linux/triblade/axon_if.h =================================================================== --- /dev/null +++ linux-2.6.23.1/include/linux/triblade/axon_if.h @@ -0,0 +1,147 @@ +/** + * axon_if - provides driver access to axon driver. Used by apnet driver + * to provide a point-to-point ethernet using axon sma and dma. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright (C) IBM Corporation, 2007, 2008 + * + * Authors: H Brett Bolen , + * Tim Schimke , + * Jesse Arroyo , + * Murali N Iyer + * + */ + +#ifndef __AXON_IF_H__ +#define __AXON_IF_H__ + + +/* + * Following message types are used by the notify functions. + * Values 0 to 7 will generate "wake-up" interrupts to the remote system. + * Values 8 to 15 will generate call-backs on the local system. + */ +enum message_type { + D2D_MSG_TYPE = 0, /* base driver to driver notification */ + APNET_MSG_TYPE = 1, /* apnet ethernet notification */ + DACS_MSG_TYPE = 2, /* DACS interface notification */ + DMA_LOCAL_MSG_TYPE = 3, /* notification to system that initiated */ + /* a DMA */ + DMA2_LOCAL_MSG_TYPE = 4, /* notification to system that initiated */ + /* a DMA */ + DMA_REMOTE_MSG_TYPE = 5, /* notification to system that didn't */ + /* initiate the DMA */ + DMA2_REMOTE_MSG_TYPE = 6 /* notification to system that didn't */ + /* initiate the DMA */ + /* type 7 reserved for other remote notifications */ + /* types 8 - 15 reserved for local callbacks */ +}; + +/** + * axon_get_num_devices - called by apnet + * + * Returns 0 if no device(s) found, positive number for number of devices found + * (typically 1-4) or -1 for error + */ +int axon_get_num_devices( void ); + +/** + * axon_get_remote_memory - called by apnet + * @dev_num - Device number ( typically 0 - 3 ) + * + * Returns NULL if remote system is not ready or driver not loaded on remote + * or ioremapped memory address of the remote system + */ +void __iomem *axon_get_remote_memory(int dev_num); + +/** + * axon_get_local_memory - called by apnet + * @dev_num - Device number ( typically 0 - 3 ) + * @size - requsted size of the shared memory in bytes + * + * Returns NULL if not allocated or not enough shared memory available + * or virtual memory address of the local system + */ + +void *axon_get_local_memory(int dev_num, size_t size); + +/** + * axon_register_notify_callback, axon_unregister_notify_callback, + * axon_enable_notify_callback, axon_disable_notify_callback and + * axon_send_remote_notification - for apnet interface + * + * @message_type - Type of the unique message number, see enum message_type + * @dev_num - Device number ( typically 0 - 3 ) + * @p_data - Private data pointer, passed with call back + * @cb_func - call back function + * + * Returns 0 for success or -ve value for error + * + * Registered function will be called back with message_type and + * pointer to private data provided during registration. + */ + +/* callback prototype */ +typedef int (*axon_callback)( int type, + void *callback_data); + +int axon_register_notify_callback( enum message_type msg_type, int dev_num, + void *p_data, + axon_callback p_func); +void axon_unregister_notify_callback( enum message_type msg_type, int dev_num); + +void axon_enable_notify_callback( enum message_type msg_type, int dev_num); +void axon_disable_notify_callback( enum message_type msg_type, int dev_num); + +void axon_send_remote_notification( enum message_type msg_type, int dev_num); + + +enum { + AXON_APNET_DMATYPE_PUT = 0x00000001, /* dma local to remote */ + AXON_APNET_DMATYPE_GET = 0x00000002, /* dma remote to local */ + AXON_APNET_DMA_CALLBACK = 0x04000000 /* request a callback + * when DMA is complete + */ +}; + + +/* helper mapping functions for apnet */ +int axon_dma_map_single(int dev_num, void *addr, + size_t size, int dir, dma_addr_t *handle); + +void axon_dma_unmap_single(int dev_num, dma_addr_t handle, + size_t size, int dir); + +struct axon_apnet_dma_cb { + dma_addr_t local_buf; /* DMA mapped address for the local memory */ + u64 remote_offset; /* Physical address of the remote memory for data */ + int length; /* Length in bytes of transfer */ + int flags; + /* DMA mapped address for the local status value */ + dma_addr_t local_status; + int remote_status_offset; /* location to write status value */ + axon_callback cb_func; /* temporary plumbing for callback */ + void *cb_data; /* pointer to return on callback */ +}; + +/** + * axon_apnet_dma - Perform a DMA within the apnet memory area + * @dev_num: Device number ( typically 0 - 3 ) + * @cb: apnet dma request control block + */ +int axon_apnet_dma(int dev_num, struct axon_apnet_dma_cb *cb); + +#endif /* __AXON_IF_H__ */ Index: linux-2.6.23.1/include/linux/triblade/axon_ioctl.h =================================================================== --- /dev/null +++ linux-2.6.23.1/include/linux/triblade/axon_ioctl.h @@ -0,0 +1,149 @@ +/** + * axon_ioctl - provides an io control interface to the axon driver + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright (C) IBM Corporation, 2008 + * + * Authors: H Brett Bolen , + * Tim Schimke , + * Jesse Arroyo , + * Murali N Iyer + * + */ + + +#ifndef __AXON_IOCTL_H__ +#define __AXON_IOCTL_H__ + +#define AXONIO_IOC_MAGIC 'x' + +/* DMA Memory Registration */ +#define AXONIO_DMA_REGISTER _IOWR(AXONIO_IOC_MAGIC, 0x7, \ + struct AXON_MR_registration) +#define AXONIO_DMA_DEREGISTER _IOWR(AXONIO_IOC_MAGIC, 0x8, \ + struct AXON_MR_deregistration) +#define AXONIO_DMA_EXTREGISTER _IOWR(AXONIO_IOC_MAGIC, 0x10, \ + struct AXON_MR_ext_registration) +#define AXONIO_ISSUE_DMA_FAST _IOWR(AXONIO_IOC_MAGIC, 0x11, __u32) + +/* Wakeup Notificaton of remote system */ +#define AXONIO_NOTIFY _IOR(AXONIO_IOC_MAGIC, 0x13, __u32) + + +/* + * mmap offsets + */ +#define LOCAL_SMA_OFFSET 0x0 +#define REMOTE_SMA_OFFSET 0x0100000 +#define DMA_COMMAND_BUFFER_OFFSET 0x0800000 + + +/* + * opaque handles + */ +typedef __u64 AXON_memory_region_handle; + +/** + * Supports Memory Registration + * AXON_DMA_REGISTER + * AXON_DMA_DEREGISTER + * + * permissions bitmask + * + * 0x01 - allow local access ( always true) + * 0x02 - allow local read + * 0x04 - allow local write + * 0x10 - allow remote access + * 0x20 - allow remote read + * 0x40 - allow remote write + */ + +enum { + AXON_MR_LOCAL_ACCESS = 0x00000001, + AXON_MR_LOCAL_READ = 0x00000002, + AXON_MR_LOCAL_WRITE = 0x00000004, + AXON_MR_REMOTE_ACCESS = 0x00000010, + AXON_MR_REMOTE_READ = 0x00000020, + AXON_MR_REMOTE_WRITE = 0x00000040, +}; + + +struct AXON_MR_registration{ + AXON_memory_region_handle memory_region_handle; + __u64 local_dma_memory; + __u64 local_dma_memory_size; + __u64 permissions; +}; + +struct AXON_MR_deregistration{ + AXON_memory_region_handle memory_region_handle; +}; + +struct AXON_MR_ext_registration{ + AXON_memory_region_handle memory_region_handle; + __u64 permissions; +}; + +/** + * Supports DMA GET/PUT status queries + * + * NOTE: AXON_dma_request required to be within SMA area + */ + +struct AXON_dma_list_entry { + AXON_memory_region_handle src_memory_region_handle; + __u64 src_address; + __u64 transfer_size; + /* total size 0x18 */ +}; + +enum { + AXON_DMATYPE_PUT = 0x01, /* dma local to remote */ + AXON_DMATYPE_GET = 0x02, /* dma remote to local */ +}; + +enum { + AXON_DMAFLAG_WRITE_REMOTE_STATUS = 0x00000001, + AXON_DMAFLAG_LOCAL_COMPLETION_SIGNAL = 0x00000002, +}; + +struct AXON_dma_request { + __u32 dma_type; + __u32 flags; + __u32 localDmaStatusOffset; + __u32 remoteDmaStatusOffset; + __u64 transfer_size; /* bytes */ + __u32 local_descriptor_count; + __u32 remote_descriptor_count; + __u64 rsvd1; + struct AXON_dma_list_entry local_descriptor[10]; + struct AXON_dma_list_entry remote_descriptor[10]; +}; +struct AXON_dma_command_list_fast { + __u32 dma_requests_available; + __u32 dma_requests_started; + __u32 dma_req_offset; /* offset into command block mmap area */ +}; + +/** + * Wakeup Notificaton + */ +struct AXON_WAKEUP { + __u32 type; +}; + + +#endif /* __AXON_IOCTL_H__ */ --