CINXE.COM

LKML: Roland Dreier: [PATCH 01/13] [RFC] ipath basic headers

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Roland Dreier: [PATCH 01/13] [RFC] ipath basic headers</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Roland Dreier" href="/groupie.php?aid=3215" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/12"> [Dec]</a> 聽 <a class="nb" href="/lkml/2005/12/16"> [16]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2005/12/16/293" onclick="this.href='/lkml/headers'+'/2005/12/16/293';">[headers]</a>聽 <a href="/lkml/bounce/2005/12/16/293">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2005/12/16/290">First message in thread</a></li><li><a href="/lkml/2005/12/16/290">Roland Dreier</a><ul><li class="origin"><a href="/lkml/2005/12/16/289">Roland Dreier</a><ul><li><a href="/lkml/2005/12/16/289">Roland Dreier</a><ul><li><a href="/lkml/2005/12/16/291">Roland Dreier</a><ul><li><a href="/lkml/2005/12/16/303">Roland Dreier</a></li><li><a href="/lkml/2005/12/17/25">Pekka Enberg</a></li><li><a href="/lkml/2005/12/17/31">Christoph Hellwig</a></li><li><a href="/lkml/2005/12/17/78">Andrew Morton</a></li></ul></li></ul></li><li><a href="/lkml/2005/12/17/23">Pekka Enberg</a><ul><li><a href="/lkml/2005/12/17/97">Robert Walsh</a></li></ul></li><li><a href="/lkml/2005/12/17/29">Christoph Hellwig</a><ul><li><a href="/lkml/2005/12/17/96">(Eric W. Biederman)</a><ul><li><a href="/lkml/2005/12/17/129">Andi Kleen</a></li></ul></li><li><a href="/lkml/2005/12/17/98">Robert Walsh</a><ul><li><a href="/lkml/2005/12/17/100">Arjan van de Ven</a></li></ul></li></ul></li><li><a href="/lkml/2005/12/17/77">Andrew Morton</a><ul><li><a href="/lkml/2005/12/17/102">Robert Walsh</a><ul><li><a href="/lkml/2005/12/17/126">Andrew Morton</a></li></ul></li><li><a href="/lkml/2005/12/19/207">Robert Walsh</a></li></ul></li></ul></li><li><a href="/lkml/2005/12/17/30">Christoph Hellwig</a><ul><li><a href="/lkml/2005/12/17/37">Roland Dreier</a></li></ul></li></ul></li></ul><div class="threadlist">Patch in this message</div><ul class="threadlist"><li><a href="/lkml/diff/2005/12/16/293/1">Get diff 1</a></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Subject</td><td class="rp" itemprop="name">[PATCH 01/13] [RFC] ipath basic headers</td></tr><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Fri, 16 Dec 2005 15:48:54 -0800</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Roland Dreier &lt;&gt;</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">Basic headers for the ipath driver<br /><br />---<br /><br /> drivers/infiniband/hw/ipath/ipath_common.h | 798 +++++++++++++++++++++++++<br /> drivers/infiniband/hw/ipath/ipath_kernel.h | 776 ++++++++++++++++++++++++<br /> drivers/infiniband/hw/ipath/ipath_layer.h | 131 ++++<br /> drivers/infiniband/hw/ipath/ipath_registers.h | 359 +++++++++++<br /> drivers/infiniband/hw/ipath/ips_common.h | 221 +++++++<br /> 5 files changed, 2285 insertions(+), 0 deletions(-)<br /> create mode 100644 drivers/infiniband/hw/ipath/ipath_common.h<br /> create mode 100644 drivers/infiniband/hw/ipath/ipath_kernel.h<br /> create mode 100644 drivers/infiniband/hw/ipath/ipath_layer.h<br /> create mode 100644 drivers/infiniband/hw/ipath/ipath_registers.h<br /> create mode 100644 drivers/infiniband/hw/ipath/ips_common.h<br /><br />200aa6cff25b6ab39be1f9d8949c2b3b4258ee1d<br />diff --git a/drivers/infiniband/hw/ipath/ipath_common.h b/drivers/infiniband/hw/ipath/ipath_common.h<br />new file mode 100644<br />index 0000000..ac33458<br />--- /dev/null<br />+++ b/drivers/infiniband/hw/ipath/ipath_common.h<br />&#64;&#64; -0,0 +1,798 &#64;&#64;<br />+/*<br />+ * Copyright (c) 2003, 2004, 2005. PathScale, Inc. All rights reserved.<br />+ *<br />+ * This software is available to you under a choice of one of two<br />+ * licenses. You may choose to be licensed under the terms of the GNU<br />+ * General Public License (GPL) Version 2, available from the file<br />+ * COPYING in the main directory of this source tree, or the<br />+ * OpenIB.org BSD license below:<br />+ *<br />+ * Redistribution and use in source and binary forms, with or<br />+ * without modification, are permitted provided that the following<br />+ * conditions are met:<br />+ *<br />+ * - Redistributions of source code must retain the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer.<br />+ *<br />+ * - Redistributions in binary form must reproduce the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer in the documentation and/or other materials<br />+ * provided with the distribution.<br />+ *<br />+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br />+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br />+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br />+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS<br />+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br />+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br />+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />+ * SOFTWARE.<br />+ *<br />+ * Patent licenses, if any, provided herein do not apply to<br />+ * combinations of this program with other software, or any other<br />+ * product whatsoever.<br />+ *<br />+ * $Id: ipath_common.h 4491 2005-12-15 22:20:31Z rjwalsh $<br />+ */<br />+<br />+#ifndef _IPATH_COMMON_H<br />+#define _IPATH_COMMON_H<br />+<br />+/*<br />+ * This file contains defines, structures, etc. that are used<br />+ * to communicate between kernel and user code.<br />+ */<br />+<br />+#ifdef __KERNEL__<br />+#include &lt;linux/ioctl.h&gt;<br />+#include &lt;linux/uio.h&gt;<br />+#include &lt;asm/atomic.h&gt;<br />+#else /* !__KERNEL__; user mode */<br />+#include &lt;sys/ioctl.h&gt;<br />+#include &lt;sys/uio.h&gt;<br />+#include &lt;sys/types.h&gt;<br />+#include &lt;stdint.h&gt;<br />+<br />+/* these aren't implemented for user mode, which is OK until we multi-thread */<br />+typedef struct _atomic {<br />+ uint32_t counter;<br />+} atomic_t; /* no atomic_t type in user-land */<br />+#define atomic_set(a,v) ((a)-&gt;counter = (v))<br />+#define atomic_inc_return(a) (++(a)-&gt;counter)<br />+#define likely(x) (x)<br />+#define unlikely(x) (x)<br />+<br />+#define yield() sched_yield()<br />+<br />+/*<br />+ * too horrible to try and use the kernel get_cycles() or equivalent,<br />+ * so define and inline it here<br />+ */<br />+<br />+#if !defined(rdtscll)<br />+#if defined(__x86_64) || defined(__i386)<br />+#define rdtscll(v) do {uint32_t a,d;asm volatile("rdtsc" : "=a" (a), "=d" (d)); \<br />+ (v) = ((uint64_t)a) | (((uint64_t)d)&lt;&lt;32); \<br />+} while(0)<br />+#else<br />+#error "No cycle counter routine implemented yet for this platform"<br />+#endif<br />+#endif /* !defined(rdtscll) */<br />+<br />+#endif /* ! __KERNEL__ */<br />+<br />+typedef uint8_t ipath_type;<br />+<br />+/* This is the IEEE-assigned OUI for PathScale, Inc. */<br />+#define IPATH_SRC_OUI_1 0x00<br />+#define IPATH_SRC_OUI_2 0x11<br />+#define IPATH_SRC_OUI_3 0x75<br />+<br />+/* version of protocol header (known to chip also). In the long run,<br />+ * we should be able to generate and accept a range of version numbers;<br />+ * for now we only accept one, and it's compiled in.<br />+ */<br />+#define IPS_PROTO_VERSION 2<br />+<br />+#ifndef _BITS_PER_BYTE<br />+#define _BITS_PER_BYTE 8<br />+#endif<br />+<br />+static __inline__ void ipath_shortcopy(void *dest, void *src, uint32_t cnt)<br />+ __attribute__ ((always_inline));<br />+<br />+/*<br />+ * this is used for very short copies, usually 1 - 8 bytes,<br />+ * *NEVER* to the PIO buffers!!!!!!! use ipath_dwordcpy for longer<br />+ * copies, or any copy to the PIO buffers. Works for 32 and 64 bit<br />+ * gcc and pathcc<br />+ */<br />+static __inline__ void ipath_shortcopy(void *dest, void *src, uint32_t cnt)<br />+{<br />+ void *ssv, *dsv;<br />+ uint32_t csv;<br />+ __asm__ __volatile__("cld\n\trep\n\tmovsb":"=&amp;c"(csv), "=&amp;D"(dsv),<br />+ "=&amp;S"(ssv)<br />+ :"0"(cnt), "1"(dest), "2"(src)<br />+ :"memory");<br />+}<br />+<br />+/*<br />+ * optimized word copy; good for rev C and later opterons. Among the best for<br />+ * short copies, and does as well or slightly better than the optimizization<br />+ * guide copies 6 and 8 at 2KB.<br />+ */<br />+void ipath_dwordcpy(uint32_t * dest, uint32_t * src, uint32_t ndwords);<br />+<br />+/*<br />+ * These are compile time constants that you may want to enable or disable<br />+ * if you are trying to debug problems with code or performance.<br />+ * IPATH_VERBOSE_TRACING define as 1 if you want additional tracing in<br />+ * fastpath code<br />+ * IPATH_TRACE_REGWRITES define as 1 if you want register writes to be<br />+ * traced in faspath code<br />+ * _IPATH_TRACING define as 0 if you want to remove all tracing in a<br />+ * compilation unit<br />+ * _IPATH_DEBUGGING define as 0 if you want to remove debug prints<br />+ */<br />+<br />+#define round_up(v,sz) (((v) + (sz)-1) &amp; ~((sz)-1))<br />+<br />+/* These are used in the driver, don't use them elsewhere */<br />+#define _IPATH_SIMFUNC_IOCTL_LOW 1<br />+#define _IPATH_SIMFUNC_IOCTL_HIGH 7<br />+<br />+/*<br />+ * These tell the driver which ioctl's belong to the diags interface.<br />+ * As above, don't use them elsewhere.<br />+ */<br />+#define _IPATH_DIAG_IOCTL_LOW 100<br />+#define _IPATH_DIAG_IOCTL_HIGH 109<br />+<br />+/* for IPATHSETREGBASE the length is the length covered by addr, in bytes */<br />+struct ipath_setregbase {<br />+ void *addr;<br />+ size_t length;<br />+};<br />+/*<br />+ * IPATHINTERRUPT ioctl passes this as of rev 1.6 of the simulator;<br />+ * used to be an int<br />+ */<br />+struct ipath_int_vec {<br />+ int long long addr;<br />+ uint32_t info;<br />+};<br />+struct ipath_eeprom_req {<br />+ long long addr;<br />+ uint16_t len;<br />+ uint16_t offset;<br />+};<br />+<br />+/* simulated chip space */<br />+#define IPATHSETREGBASE _IOW('s', 1, struct ipath_setregbase)<br />+/* arg is currently unused */<br />+#define IPATHINTERRUPT _IOW('s', 2, struct ipath_int_vec)<br />+/*<br />+ * arg is low 32 bits of the simulator sync register, and means that<br />+ * the simulator has processed up to and including that write<br />+ */<br />+#define IPATHSYNC _IOW('s', 3, int)<br />+<br />+/*<br />+ * simulator has initialized the memory from IPATHSETREGBASE, and driver<br />+ * can initialize based on the contents<br />+ */<br />+#define IPATHREADY _IOW('s', 4, int)<br />+/* user mode userreg write, so we can notify simulators */<br />+#define IPATH_USERREG _IOW('s', 5, __ipath_rdummy)<br />+<br />+/* init; user params to kernel */<br />+#define IPATH_USERINIT _IOW('s', 16, struct ipath_user_info)<br />+/* init; kernel/chip params to user */<br />+#define IPATH_BASEINFO _IOR('s', 17, struct ipath_base_info)<br />+/* send a packet */<br />+#define IPATH_SENDPKT _IOW('s', 18, struct ipath_sendpkt)<br />+/*<br />+ * if arg is 0, disable port, used when flushing after a hdrq overflow.<br />+ * If arg ia 1, re-enable, and return new value of head register<br />+ */<br />+#define IPATH_RCVCTRL _IOR('s', 19, uint32_t)<br />+/* only to make iow macro happy, w/o a struct */<br />+static uint64_t __ipath_rdummy[2] __attribute__ ((unused));<br />+#define IPATH_READ_EEPROM _IOWR('s', 20, struct ipath_eeprom_req)<br />+/* set an accepted partition key; up to 4 pkeys can be active at once */<br />+#define IPATH_SET_PKEY _IOW('s', 21, uint16_t)<br />+#define IPATH_WRITE_EEPROM _IOWR('s', 22, struct ipath_eeprom_req)<br />+/* set LID for interface (SMA) */<br />+#define IPATH_SET_LID _IOW('s', 23, uint32_t)<br />+/* set IB MTU for interface (SMA) */<br />+#define IPATH_SET_MTU _IOW('s', 24, uint32_t)<br />+/* set IB link state for interface (SMA) */<br />+#define IPATH_SET_LINKSTATE _IOW('s', 25, uint32_t)<br />+/* send an SMA packet, sps_flags contains "normal" SMA unit and minor number. */<br />+#define IPATH_SEND_SMA_PKT _IOW('s', 26, struct ipath_sendpkt)<br />+/* receive an SMA packet */<br />+#define IPATH_RCV_SMA_PKT _IOW('s', 27, struct ipath_sendpkt)<br />+/* get the portinfo data (SMA)<br />+ * takes array of 13, returns port info fields. Data is in host order,<br />+ * not network order; SMA-only fields are not filled in<br />+ */<br />+#define IPATH_GET_PORTINFO _IOWR('s', 28, uint32_t *)<br />+/*<br />+ * get the nodeinfo data (SMA)<br />+ * takes an array of 10, returns nodeinfo fields in host order<br />+ */<br />+#define IPATH_GET_NODEINFO _IOWR('s', 29, uint32_t *)<br />+/* set GUID on interface (SMA; GUID given in network order) */<br />+#define IPATH_SET_GUID _IOW('s', 30, struct ipath_setguid)<br />+/* set MLID for interface (SMA) */<br />+#define IPATH_SET_MLID _IOW('s', 31, uint32_t)<br />+#define IPATH_GET_MLID _IOWR('s', 32, uint32_t *) /* get the MLID (SMA) */<br />+/* update expected TID entries */<br />+#define IPATH_UPDM_TID _IOWR('s', 33, struct _tidupd)<br />+/* free expected TID entries */<br />+#define IPATH_FREE_TID _IOW('s', 34, struct _tidupd)<br />+/* return assigned unit:port */<br />+#define IPATH_GETPORT _IOR('s', 35, uint32_t)<br />+/* wait for rcv pkt or pioavail */<br />+#define IPATH_WAIT _IOW('s', 36, uint32_t)<br />+/* return LID for passed in unit */<br />+#define IPATH_GETLID _IOR('s', 37, uint16_t)<br />+/* return # of units supported by driver */<br />+#define IPATH_GETUNITS _IO('s', 38)<br />+/* get the device status */<br />+#define IPATH_GET_DEVSTATUS _IOWR('s', 39, uint64_t *)<br />+<br />+/* available for reuse ('s', 48) */<br />+<br />+/* diagnostic read */<br />+#define IPATH_DIAGREAD _IOR('s', 100, struct ipath_diag_info)<br />+/* diagnostic write */<br />+#define IPATH_DIAGWRITE _IOW('s', 101, struct ipath_diag_info)<br />+/* HT Config read */<br />+#define IPATH_DIAG_HTREAD _IOR('s', 102, struct ipath_diag_info)<br />+/* HT config write */<br />+#define IPATH_DIAG_HTWRITE _IOW('s', 103, struct ipath_diag_info)<br />+#define IPATH_DIAGENTER _IO('s', 104) /* Enter diagnostic mode */<br />+#define IPATH_DIAGLEAVE _IO('s', 105) /* Leave diagnostic mode */<br />+/* send a packet, sps_flags contains unit and minor number. */<br />+#define IPATH_SEND_DIAG_PKT _IOW('s', 106, struct ipath_sendpkt)<br />+/*<br />+ * read I2C FLASH<br />+ * NOTE: To read the I2C device, the _uaddress field should contain <br />+ * a pointer to struct ipath_eeprom_req, and _unit must be valid<br />+ */<br />+#define IPATH_DIAG_RD_I2C _IOW('s', 107, struct ipath_diag_info)<br />+<br />+/*<br />+ * Monitoring ioctls. All of these work with the main device<br />+ * (/dev/ipath), if you don't mind using a port (e.g. you already have<br />+ * the device open.) IPATH_GETSTATS and IPATH_GETUNITCOUNTERS also<br />+ * work with the control device (/dev/ipath_ctrl), if you don't want to<br />+ * use a port.<br />+ */<br />+<br />+/* return chip counters for current unit. */<br />+#define IPATH_GETCOUNTERS _IOR('s', 40, struct infinipath_counters)<br />+/* return chip stats */<br />+#define IPATH_GETSTATS _IOR('s', 41, struct infinipath_stats)<br />+/* return chip counters for a particular unit. */<br />+#define IPATH_GETUNITCOUNTERS _IOR('s', 42, struct infinipath_getunitcounters)<br />+<br />+/*<br />+ * unit is incoming unit number.<br />+ * data is a pointer to the infinipath_counters structure.<br />+ */<br />+struct infinipath_getunitcounters {<br />+ uint16_t unit;<br />+ uint64_t data;<br />+};<br />+<br />+/*<br />+ * The value in the BTH QP field that InfiniPath uses to differentiate<br />+ * an infinipath protocol IB packet vs standard IB transport<br />+ */<br />+#define IPATH_KD_QP 0x656b79<br />+<br />+/*<br />+ * valid states passed to ipath_set_linkstate() user call<br />+ * (IPATH_SET_LINKSTATE ioctl)<br />+ */<br />+#define IPATH_IB_LINKDOWN 0<br />+#define IPATH_IB_LINKARM 1<br />+#define IPATH_IB_LINKACTIVE 2<br />+<br />+/*<br />+ * stats maintained by the driver. For now, at least, this is global<br />+ * to all minor devices.<br />+ */<br />+struct infinipath_stats {<br />+ uint64_t sps_ints; /* number of interrupts taken */<br />+ uint64_t sps_errints; /* number of interrupts for errors */<br />+ /* number of errors from chip (not including packet errors or CRC) */<br />+ uint64_t sps_errs;<br />+ /* number of packet errors from chip other than CRC */<br />+ uint64_t sps_pkterrs;<br />+ /* number of packets with CRC errors (ICRC and VCRC) */<br />+ uint64_t sps_crcerrs;<br />+ /* number of hardware errors reported (parity, etc.) */<br />+ uint64_t sps_hwerrs;<br />+ /* number of times IB link changed state unexpectedly */<br />+ uint64_t sps_iblink;<br />+ uint64_t sps_unused3; /* no longer used; left for compatibility */<br />+ uint64_t sps_port0pkts; /* number of kernel (port0) packets received */<br />+ /* number of "ethernet" packets sent by driver */<br />+ uint64_t sps_ether_spkts;<br />+ /* number of "ethernet" packets received by driver */<br />+ uint64_t sps_ether_rpkts;<br />+ uint64_t sps_sma_spkts; /* number of SMA packets sent by driver */<br />+ uint64_t sps_sma_rpkts; /* number of SMA packets received by driver */<br />+ /* number of times all ports rcvhdrq was full and packet dropped */<br />+ uint64_t sps_hdrqfull;<br />+ /* number of times all ports egrtid was full and packet dropped */<br />+ uint64_t sps_etidfull;<br />+ /*<br />+ * number of times we tried to send from driver, but no pio<br />+ * buffers avail<br />+ */<br />+ uint64_t sps_nopiobufs;<br />+ uint64_t sps_ports; /* number of ports currently open */<br />+ /* list of pkeys (other than default) accepted (0 means not set) */<br />+ uint16_t sps_pkeys[4];<br />+ /* lids for up to 4 infinipaths, indexed by infinipath # */<br />+ uint16_t sps_lid[4];<br />+ /* number of user ports per chip (not IB ports) */<br />+ uint32_t sps_nports;<br />+ uint32_t sps_nullintr; /* not our interrupt, or already handled */<br />+ uint32_t sps_maxpkts_call; /* max number of packets handled per receive call */<br />+ uint32_t sps_avgpkts_call; /* avg number of packets handled per receive call */<br />+ uint64_t sps_pagelocks; /* total number of pages ipath_mlock()'ed */<br />+ /* total number of pages ipath_munlock()'ed */<br />+ uint64_t sps_pageunlocks;<br />+ /*<br />+ * Number of packets dropped in kernel other than errors<br />+ * (ether packets if ipath not configured, sma/mad, etc.)<br />+ */<br />+ uint64_t sps_krdrops;<br />+ /* mlids for up to 4 infinipaths, indexed by infinipath # */<br />+ uint16_t sps_mlid[4];<br />+ uint64_t __sps_pad[45]; /* pad for future growth */<br />+};<br />+<br />+/*<br />+ * These are the status bits returned (in ascii form, 64bit value)<br />+ * by the IPATH_GETSTATS ioctl.<br />+ */<br />+#define IPATH_STATUS_INITTED 0x1 /* basic driver initialization done */<br />+#define IPATH_STATUS_DISABLED 0x2 /* hardware disabled */<br />+#define IPATH_STATUS_UNUSED 0x4 /* available */<br />+#define IPATH_STATUS_OIB_SMA 0x8 /* ipath_mad kernel SMA running */<br />+#define IPATH_STATUS_SMA 0x10 /* user SMA running */<br />+/* Chip (simulator) has been found and initted */<br />+#define IPATH_STATUS_CHIP_PRESENT 0x20<br />+#define IPATH_STATUS_IB_READY 0x40 /* IB link is at ACTIVE, has LID,<br />+ * usable for all VL's */<br />+/* after link up, LID,MTU,etc. has been configured */<br />+#define IPATH_STATUS_IB_CONF 0x80<br />+/* no link established, probably no cable */<br />+#define IPATH_STATUS_IB_NOCABLE 0x100<br />+/* A Fatal hardware error has occurred. */<br />+#define IPATH_STATUS_HWERROR 0x200<br />+<br />+/* The list of usermode accessible registers. Also see Reg_* later in file */<br />+typedef enum _ipath_ureg {<br />+ ur_rcvhdrtail = 0, /* (RO) DMA RcvHdr to be used next. */<br />+ /* (RW) RcvHdr entry to be processed next by host. */<br />+ ur_rcvhdrhead = 1,<br />+ ur_rcvegrindextail = 2, /* (RO) Index of next Eager index to use. */<br />+ ur_rcvegrindexhead = 3, /* (RW) Eager TID to be processed next */<br />+ /* For internal use only; max register number. */<br />+ _IPATH_UregMax<br />+} ipath_ureg;<br />+<br />+/* SMA minor# no portinfo, one for all instances */<br />+#define IPATH_SMA 128<br />+<br />+/* Control minor# no portinfo, one for all instances */<br />+#define IPATH_CTRL 130<br />+<br />+/*<br />+ * This structure is returned by ipath_userinit() immediately after open<br />+ * to get implementation-specific info, and info specific to this<br />+ * instance.<br />+ */<br />+struct ipath_base_info {<br />+ /* version of hardware, for feature checking. */<br />+ uint32_t spi_hw_version;<br />+ /* version of software, for feature checking. */<br />+ uint32_t spi_sw_version;<br />+ /* InfiniPath port assigned, goes into sent packets */<br />+ uint32_t spi_port;<br />+ /*<br />+ * IB MTU, packets IB data must be less than this.<br />+ * The MTU is in bytes, and will be a multiple of 4 bytes.<br />+ */<br />+ uint32_t spi_mtu;<br />+ /*<br />+ * size of a PIO buffer. Any given packet's total<br />+ * size must be less than this (in words). Included is the<br />+ * starting control word, so if 513 is returned, then total<br />+ * pkt size is 512 words or less.<br />+ */<br />+ uint32_t spi_piosize;<br />+ /* size of the TID cache in infinipath, in entries */<br />+ uint32_t spi_tidcnt;<br />+ /* size of the TID Eager list in infinipath, in entries */<br />+ uint32_t spi_tidegrcnt;<br />+ /* size of a single receive header queue entry. */<br />+ uint32_t spi_rcvhdrent_size;<br />+ /* Count of receive header queue entries allocated.<br />+ * This may be less than the spu_rcvhdrcnt passed in!.<br />+ */<br />+ uint32_t spi_rcvhdr_cnt;<br />+<br />+ uint32_t __32_bit_compatibility_pad; /* DO NOT MOVE OR REMOVE */<br />+<br />+ /* address where receive buffer queue is mapped into */<br />+ uint64_t spi_rcvhdr_base;<br />+<br />+ /* user program. */<br />+<br />+ /* base address of eager TID receive buffers. */<br />+ uint64_t spi_rcv_egrbufs;<br />+<br />+ /* Allocated by initialization code, not by protocol. */<br />+<br />+ /* size of each TID buffer in host memory,<br />+ * starting at spi_rcv_egrbufs. It includes spu_egrskip, and is<br />+ * at least spi_mtu bytes, and the buffers are virtually contiguous<br />+ */<br />+ uint32_t spi_rcv_egrbufsize;<br />+ /*<br />+ * The special QP (queue pair) value that identifies an infinipath<br />+ * protocol packet from standard IB packets. More, probably much<br />+ * more, to be added.<br />+ */<br />+ uint32_t spi_qpair;<br />+<br />+ /*<br />+ * user register base for init code, not to be used directly by<br />+ * protocol or applications<br />+ */<br />+ uint64_t __spi_uregbase;<br />+ /*<br />+ * maximum buffer size in bytes that can be used in a<br />+ * single TID entry (assuming the buffer is aligned to this boundary).<br />+ * This is the minimum of what the hardware and software support<br />+ * Guaranteed to be a power of 2.<br />+ */<br />+ uint32_t spi_tid_maxsize;<br />+ /*<br />+ * alignment of each pio send buffer (byte count<br />+ * to add to spi_piobufbase to get to second buffer)<br />+ */<br />+ uint32_t spi_pioalign;<br />+ /*<br />+ * the index of the first pio buffer available<br />+ * to this process; needed to do lookup in spi_pioavailaddr; not added <br />+ * to spi_piobufbase<br />+ */<br />+ uint32_t spi_pioindex;<br />+ uint32_t spi_piocnt; /* number of buffers mapped for this process */<br />+<br />+ /*<br />+ * base address of writeonly pio buffers for this process.<br />+ * Each buffer has spi_piosize words, and is aligned on spi_pioalign<br />+ * boundaries. spi_piocnt buffers are mapped from this address<br />+ */<br />+ uint64_t spi_piobufbase;<br />+<br />+ /*<br />+ * base address of readonly memory copy of the pioavail registers.<br />+ * There are 2 bits for each buffer.<br />+ */<br />+ uint64_t spi_pioavailaddr;<br />+<br />+ /*<br />+ * Address where driver updates a copy<br />+ * of the interface and driver status (IPATH_STATUS_*) as a 64 bit value<br />+ * It's followed by a string indicating hardware error, if there was one<br />+ */<br />+ uint64_t spi_status;<br />+<br />+ /* number of chip ports available to user processes */<br />+ uint32_t spi_nports;<br />+ uint32_t spi_unit; /* unit number of chip we are using */<br />+ uint32_t spi_rcv_egrperchunk; /* num bufs in each contiguous set */<br />+ /* size in bytes of each contiguous set */<br />+ uint32_t spi_rcv_egrchunksize;<br />+ /* total size of mmap to cover full rcvegrbuffers */<br />+ uint32_t spi_rcv_egrbuftotlen;<br />+ /*<br />+ * ioctl cmd includes struct size, so pad out, and adjust down as<br />+ * new fields are added to keep size constant<br />+ */<br />+ uint32_t __spi_pad[19];<br />+} __attribute__ ((aligned(8)));<br />+<br />+#define IPATH_WAIT_RCV 0x1 /* IPATH_WAIT, receive */<br />+#define IPATH_WAIT_PIO 0x2 /* IPATH_WAIT, PIO */<br />+<br />+/*<br />+ * This version number is given to the driver by the user code during<br />+ * initialization in the spu_userversion field of ipath_user_info, so<br />+ * the driver can check for compatibility with user code.<br />+ *<br />+ * The major version changes when data structures<br />+ * change in an incompatible way. The driver must be the same or higher<br />+ * for initialization to succeed. In some cases, a higher version<br />+ * driver will not interoperate with older software, and initialization<br />+ * will return an error.<br />+ */<br />+#define IPATH_USER_SWMAJOR 1<br />+<br />+/*<br />+ * Minor version differences are always compatible<br />+ * a within a major version, however if if user software is larger<br />+ * than driver software, some new features and/or structure fields<br />+ * may not be implemented; the user code must deal with this if it<br />+ * cares, or it must abort after initialization reports the difference<br />+ */<br />+#define IPATH_USER_SWMINOR 2<br />+<br />+#define IPATH_USER_SWVERSION ((IPATH_USER_SWMAJOR&lt;&lt;16) | IPATH_USER_SWMINOR)<br />+<br />+/* Similarly, this is the kernel version going back to the user. It's slightly<br />+ * different, in that we want to tell if the driver was built as part of a<br />+ * PathScale release, or from the driver from the OpenIB, kernel.org, or a<br />+ * standard distribution, for support reasons. The high bit is 0 for<br />+ * non-PathScale, and 1 for PathScale-built/supplied. That bit is defined<br />+ * in Makefiles, rather than this file.<br />+ *<br />+ * It's returned by the driver to the user code during initialization<br />+ * in the spi_sw_version field of ipath_base_info, so the user code can<br />+ * in turn check for compatibility with the kernel.<br />+*/<br />+#define IPATH_KERN_SWVERSION ((IPATH_KERN_TYPE&lt;&lt;31) | IPATH_USER_SWVERSION)<br />+<br />+/*<br />+ * This structure is passed to ipath_userinit() to tell the driver where<br />+ * user code buffers are, sizes, etc.<br />+ */<br />+struct ipath_user_info {<br />+ /*<br />+ * version of user software, to detect compatibility issues.<br />+ * Should be set to IPATH_USER_SWVERSION.<br />+ */<br />+ uint32_t spu_userversion;<br />+<br />+ /* desired number of receive header queue entries */<br />+ uint32_t spu_rcvhdrcnt;<br />+<br />+ /*<br />+ * Leave this much unused space at the start of<br />+ * each eager buffer for software use. Similar in effect to<br />+ * setting K_Offset to this value. needs to be 'small', on the<br />+ * order of one or two cachelines<br />+ */<br />+ uint32_t spu_egrskip;<br />+<br />+ /*<br />+ * number of words in KD protocol header<br />+ * This tells InfiniPath how many words to copy to rcvhdrq. If 0,<br />+ * kernel uses a default. Once set, attempts to set any other value<br />+ * are an error (EAGAIN) until driver is reloaded.<br />+ */<br />+ uint32_t spu_rcvhdrsize;<br />+<br />+ /*<br />+ * cache line aligned (64 byte) user address to<br />+ * which the rcvhdrtail register will be written by infinipath<br />+ * whenever it changes, so that no chip registers are read in<br />+ * the performance path.<br />+ */<br />+ uint64_t spu_rcvhdraddr;<br />+<br />+ /*<br />+ * ioctl cmd includes struct size, so pad out,<br />+ * and adjust down as new fields are added to keep size constant<br />+ */<br />+ uint32_t __spu_pad[6];<br />+} __attribute__ ((aligned(8)));<br />+<br />+struct ipath_iovec {<br />+ /* Pointer to data, but same size 32 and 64 bit */<br />+ uint64_t iov_base;<br />+<br />+ /*<br />+ * Length of data; don't need 64 bits, but want<br />+ * ipath_sendpkt to remain same size as before 32 bit changes, so...<br />+ */<br />+ uint64_t iov_len;<br />+};<br />+<br />+/*<br />+ * Describes a single packet for send. Each packet can have one or more<br />+ * buffers, but the total length (exclusive of IB headers) must be less<br />+ * than the MTU, and if using the PIO method, entire packet length,<br />+ * including IB headers, must be less than the ipath_piosize value (words).<br />+ * Use of this necessitates including sys/uio.h<br />+ */<br />+struct ipath_sendpkt {<br />+ uint32_t sps_flags; /* flags for packet (TBD) */<br />+ uint32_t sps_cnt; /* number of entries to use in sps_iov */<br />+ /* array of iov's describing packet. TEMPORARY */<br />+ struct ipath_iovec sps_iov[4];<br />+};<br />+<br />+struct _tidupd { /* used only in inlined function for ioctl. */<br />+ uint32_t tidcnt;<br />+ uint32_t tid__unused; /* make structure same size in 32 and 64 bit */<br />+ uint64_t tidvaddr; /* virtual address of first page in transfer */<br />+ /* pointer (same size 32/64 bit) to uint16_t tid array */<br />+ uint64_t tidlist;<br />+<br />+ /*<br />+ * pointer (same size 32/64 bit) to bitmap of TIDs used<br />+ * for this call; checked for being large enough at open<br />+ */<br />+ uint64_t tidmap;<br />+};<br />+<br />+struct ipath_setguid { /* set GUID for interface */<br />+ uint64_t sguid; /* in network order */<br />+ uint64_t sunit; /* unit number of interface */<br />+};<br />+<br />+/*<br />+ * Structure used to send data to and receive data from a diags ioctl.<br />+ *<br />+ * NOTE: For HT reads and writes, we only support byte, word (16bits) and<br />+ * dword (32bits). All other sizes for HT are invalid.<br />+ */<br />+struct ipath_diag_info {<br />+ uint64_t _base_offset; /* register to start reading from */<br />+ uint64_t _num_bytes; /* number of bytes to read or write */<br />+ /*<br />+ * address in user space.<br />+ * for reads, this is the address to store the read result(s).<br />+ * for writes, it the address to get the write data from.<br />+ * This memory better be valid in user space!<br />+ */<br />+ uint64_t _uaddress;<br />+ uint64_t _unit; /* Unit ID of chip we are accessing. */<br />+ uint64_t _pad[15];<br />+};<br />+<br />+/*<br />+ * Data layout in I2C flash (for GUID, etc.)<br />+ * All fields are little-endian binary unless otherwise stated<br />+ */<br />+#define IPATH_FLASH_VERSION 1<br />+struct ipath_flash {<br />+ uint8_t if_fversion; /* flash layout version (IPATH_FLASH_VERSION) */<br />+ uint8_t if_csum; /* checksum protecting if_length bytes */<br />+ /*<br />+ * valid length (in use, protected by if_csum), including if_fversion<br />+ * and if_sum themselves)<br />+ */<br />+ uint8_t if_length;<br />+ uint8_t if_guid[8]; /* the GUID, in network order */<br />+ /* number of GUIDs to use, starting from if_guid */<br />+ uint8_t if_numguid;<br />+ uint8_t if_serial[12]; /* the board serial number, in ASCII */<br />+ uint8_t if_mfgdate[8]; /* board mfg date (YYYYMMDD ASCII) */<br />+ /* last board rework/test date (YYYYMMDD ASCII) */<br />+ uint8_t if_testdate[8];<br />+ uint8_t if_errcntp[4]; /* logging of error counts, TBD */<br />+ /* powered on hours, updated at driver unload */<br />+ uint8_t if_powerhour[2];<br />+ uint8_t if_comment[32]; /* ASCII free-form comment field */<br />+ uint8_t if_future[50]; /* 78 bytes used, min flash size is 128 bytes */<br />+};<br />+<br />+uint8_t ipath_flash_csum(struct ipath_flash *, int);<br />+<br />+/*<br />+ * These are the counters implemented in the chip, and are listed in order.<br />+ * They are returned in this order by the IPATH_GETCOUNTERS ioctl<br />+ */<br />+struct infinipath_counters {<br />+ unsigned long long LBIntCnt;<br />+ unsigned long long LBFlowStallCnt;<br />+ unsigned long long Reserved1;<br />+ unsigned long long TxUnsupVLErrCnt;<br />+ unsigned long long TxDataPktCnt;<br />+ unsigned long long TxFlowPktCnt;<br />+ unsigned long long TxDwordCnt;<br />+ unsigned long long TxLenErrCnt;<br />+ unsigned long long TxMaxMinLenErrCnt;<br />+ unsigned long long TxUnderrunCnt;<br />+ unsigned long long TxFlowStallCnt;<br />+ unsigned long long TxDroppedPktCnt;<br />+ unsigned long long RxDroppedPktCnt;<br />+ unsigned long long RxDataPktCnt;<br />+ unsigned long long RxFlowPktCnt;<br />+ unsigned long long RxDwordCnt;<br />+ unsigned long long RxLenErrCnt;<br />+ unsigned long long RxMaxMinLenErrCnt;<br />+ unsigned long long RxICRCErrCnt;<br />+ unsigned long long RxVCRCErrCnt;<br />+ unsigned long long RxFlowCtrlErrCnt;<br />+ unsigned long long RxBadFormatCnt;<br />+ unsigned long long RxLinkProblemCnt;<br />+ unsigned long long RxEBPCnt;<br />+ unsigned long long RxLPCRCErrCnt;<br />+ unsigned long long RxBufOvflCnt;<br />+ unsigned long long RxTIDFullErrCnt;<br />+ unsigned long long RxTIDValidErrCnt;<br />+ unsigned long long RxPKeyMismatchCnt;<br />+ unsigned long long RxP0HdrEgrOvflCnt;<br />+ unsigned long long RxP1HdrEgrOvflCnt;<br />+ unsigned long long RxP2HdrEgrOvflCnt;<br />+ unsigned long long RxP3HdrEgrOvflCnt;<br />+ unsigned long long RxP4HdrEgrOvflCnt;<br />+ unsigned long long RxP5HdrEgrOvflCnt;<br />+ unsigned long long RxP6HdrEgrOvflCnt;<br />+ unsigned long long RxP7HdrEgrOvflCnt;<br />+ unsigned long long RxP8HdrEgrOvflCnt;<br />+ unsigned long long Reserved6;<br />+ unsigned long long Reserved7;<br />+ unsigned long long IBStatusChangeCnt;<br />+ unsigned long long IBLinkErrRecoveryCnt;<br />+ unsigned long long IBLinkDownedCnt;<br />+ unsigned long long IBSymbolErrCnt;<br />+};<br />+<br />+/*<br />+ * The next set of defines are for packet headers, and chip register<br />+ * and memory bits that are visible to and/or used by user-mode software<br />+ * The other bits that are used only by the driver or diags are in <br />+ * ipath_registers.h<br />+ */<br />+<br />+/* RcvHdrFlags bits */<br />+#define INFINIPATH_RHF_LENGTH_MASK 0x7FF<br />+#define INFINIPATH_RHF_LENGTH_SHIFT 0<br />+#define INFINIPATH_RHF_RCVTYPE_MASK 0x7<br />+#define INFINIPATH_RHF_RCVTYPE_SHIFT 11<br />+#define INFINIPATH_RHF_EGRINDEX_MASK 0x7FF<br />+#define INFINIPATH_RHF_EGRINDEX_SHIFT 16<br />+#define INFINIPATH_RHF_H_ICRCERR 0x80000000<br />+#define INFINIPATH_RHF_H_VCRCERR 0x40000000<br />+#define INFINIPATH_RHF_H_PARITYERR 0x20000000<br />+#define INFINIPATH_RHF_H_LENERR 0x10000000<br />+#define INFINIPATH_RHF_H_MTUERR 0x08000000<br />+#define INFINIPATH_RHF_H_IHDRERR 0x04000000<br />+#define INFINIPATH_RHF_H_TIDERR 0x02000000<br />+#define INFINIPATH_RHF_H_MKERR 0x01000000<br />+#define INFINIPATH_RHF_H_IBERR 0x00800000<br />+#define INFINIPATH_RHF_L_SWA 0x00008000<br />+#define INFINIPATH_RHF_L_SWB 0x00004000<br />+<br />+/* infinipath header fields */<br />+#define INFINIPATH_I_VERS_MASK 0xF<br />+#define INFINIPATH_I_VERS_SHIFT 28<br />+#define INFINIPATH_I_PORT_MASK 0xF<br />+#define INFINIPATH_I_PORT_SHIFT 24<br />+#define INFINIPATH_I_TID_MASK 0x7FF<br />+#define INFINIPATH_I_TID_SHIFT 13<br />+#define INFINIPATH_I_OFFSET_MASK 0x1FFF<br />+#define INFINIPATH_I_OFFSET_SHIFT 0<br />+<br />+/* K_PktFlags bits */<br />+#define INFINIPATH_KPF_INTR 0x1<br />+<br />+/* SendPIO per-buffer control */<br />+#define INFINIPATH_SP_LENGTHP1_MASK 0x3FF<br />+#define INFINIPATH_SP_LENGTHP1_SHIFT 0<br />+#define INFINIPATH_SP_INTR 0x80000000<br />+#define INFINIPATH_SP_TEST 0x40000000<br />+#define INFINIPATH_SP_TESTEBP 0x20000000<br />+<br />+/* SendPIOAvail bits */<br />+#define INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT 1<br />+#define INFINIPATH_SENDPIOAVAIL_CHECK_SHIFT 0<br />+<br />+#endif /* _IPATH_COMMON_H */<br />diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h<br />new file mode 100644<br />index 0000000..ba53fa3<br />--- /dev/null<br />+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h<br />&#64;&#64; -0,0 +1,776 &#64;&#64;<br />+/*<br />+ * Copyright (c) 2003, 2004, 2005. PathScale, Inc. All rights reserved.<br />+ *<br />+ * This software is available to you under a choice of one of two<br />+ * licenses. You may choose to be licensed under the terms of the GNU<br />+ * General Public License (GPL) Version 2, available from the file<br />+ * COPYING in the main directory of this source tree, or the<br />+ * OpenIB.org BSD license below:<br />+ *<br />+ * Redistribution and use in source and binary forms, with or<br />+ * without modification, are permitted provided that the following<br />+ * conditions are met:<br />+ *<br />+ * - Redistributions of source code must retain the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer.<br />+ *<br />+ * - Redistributions in binary form must reproduce the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer in the documentation and/or other materials<br />+ * provided with the distribution.<br />+ *<br />+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br />+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br />+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br />+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS<br />+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br />+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br />+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />+ * SOFTWARE.<br />+ *<br />+ * Patent licenses, if any, provided herein do not apply to<br />+ * combinations of this program with other software, or any other<br />+ * product whatsoever.<br />+ *<br />+ * $Id: ipath_kernel.h 4491 2005-12-15 22:20:31Z rjwalsh $<br />+ */<br />+<br />+#ifndef _IPATH_KERNEL_H<br />+#define _IPATH_KERNEL_H<br />+<br />+#ifndef PCI_VENDOR_ID_PATHSCALE /* not in pci.ids yet */<br />+#define PCI_VENDOR_ID_PATHSCALE 0x1fc1<br />+#define PCI_DEVICE_ID_PATHSCALE_INFINIPATH1 0xa<br />+#define PCI_DEVICE_ID_PATHSCALE_INFINIPATH2 0xd<br />+#endif<br />+<br />+/*<br />+ * This header file is the base header file for infinipath kernel code<br />+ * ipath_user.h serves a similar purpose for user code.<br />+ */<br />+<br />+#include "ipath_common.h"<br />+#include "ipath_debug.h"<br />+#include "ipath_registers.h"<br />+#include &lt;linux/timex.h&gt;<br />+#include &lt;asm/io.h&gt;<br />+<br />+/* only s/w major version of InfiniPath we can handle */<br />+#define IPATH_CHIP_VERS_MAJ 2U<br />+<br />+#define IPATH_CHIP_VERS_MIN 0U /* don't care about this except printing */<br />+<br />+extern struct infinipath_stats ipath_stats; /* temporary, maybe always */<br />+<br />+/* sysctl stuff */<br />+#define CTL_INFINIPATH 0x70736e69 /* "spin" as a hex value, top level */<br />+/* rest are in infinipath domain */<br />+#define CTL_INFINIPATH_DEBUG 1 /* infinipath_debug mask */<br />+#define CTL_INFINIPATH_TRACEMASK 2 /* trace mask */<br />+#define CTL_INFINIPATH_UNUSED 4 /* available for re-use */<br />+/* count of pio buffers reserved for kernel */<br />+#define CTL_INFINIPATH_LAYERBUF 8<br />+<br />+/* only s/w version of chip (simulator) we can handle for now */<br />+#define IPATH_CHIP_SWVERSION IPATH_CHIP_VERS_MAJ<br />+<br />+typedef struct _ipath_portdata {<br />+ /* minor number of devices, for ipath_type use */<br />+ unsigned port_unit;<br />+ /* array of struct page pointers */<br />+ struct page **port_rcvegrbuf_pages;<br />+ /* array of virtual addresses (from above) */<br />+ void **port_rcvegrbuf_virt;<br />+ void *port_rcvhdrq; /* rcvhdrq base, needs mmap before useful */<br />+ /* kernel virtual address where hdrqtail is updated */<br />+ uint64_t *port_rcvhdrtail_kvaddr;<br />+ struct page *port_rcvhdrtail_pagep; /* page * used for uaddr */<br />+ /*<br />+ * temp buffer for expected send setup, allocated at open, instead<br />+ * of each setup call<br />+ */<br />+ void *port_tid_pg_list;<br />+ wait_queue_head_t port_wait; /* when waiting for rcv or pioavail */<br />+ /*<br />+ * rcvegr bufs base, physical, must fit<br />+ * in 44 bits so 32 bit programs mmap64 44 bit works)<br />+ */<br />+ unsigned long port_rcvegr_phys;<br />+ /* for mmap of hdrq, must fit in 44 bits */<br />+ unsigned long port_rcvhdrq_phys;<br />+ /*<br />+ * the actual user address that we ipath_mlock'ed, so we can<br />+ * ipath_munlock it at close<br />+ */<br />+ unsigned long port_rcvhdrtail_uaddr;<br />+ /*<br />+ * number of opens on this instance (0 or 1; ignoring forks, dup,<br />+ * etc. for now)<br />+ */<br />+ int port_cnt;<br />+ /*<br />+ * how much space to leave at start of eager TID entries for protocol<br />+ * use, on each TID<br />+ */<br />+ unsigned port_egrskip;<br />+ unsigned port_port; /* instead of calculating it */<br />+ uint32_t port_piobufs; /* chip offset of PIO buffers for this port */<br />+ /* how many alloc_pages() chunks in port_rcvegrbuf_pages */<br />+ uint32_t port_rcvegrbuf_chunks;<br />+ uint32_t port_rcvegrbufs_perchunk; /* how many egrbufs per chunk */<br />+ /* order used with port_rcvegrbuf_pages */<br />+ uint32_t port_rcvegrbuf_order;<br />+ uint32_t port_rcvhdrq_order; /* rcvhdrq order (for free_pages) */<br />+ /* next expected TID to check when looking for free */<br />+ uint32_t port_tidcursor;<br />+ /* next expected TID to check when looking for free */<br />+ uint32_t port_flag;<br />+ /* WAIT_RCV that timed out, no interrupt */<br />+ uint32_t port_rcvwait_to;<br />+ /* WAIT_PIO that timed out, no interrupt */<br />+ uint32_t port_piowait_to;<br />+ uint32_t port_rcvnowait; /* WAIT_RCV already happened, no wait */<br />+ uint32_t port_pionowait; /* WAIT_PIO already happened, no wait */<br />+ uint32_t port_hdrqfull; /* total number of rcvhdrqfull errors */<br />+ pid_t port_pid; /* pid of process using this port */<br />+ /* same size as task_struct .comm[], but no define */<br />+ char port_comm[16];<br />+ uint16_t port_pkeys[4]; /* pkeys set by this use of this port */<br />+} ipath_portdata;<br />+<br />+struct sk_buff;<br />+<br />+/*<br />+ * control information for layered drivers<br />+ * This is used only as part of devdata via ipath_layer;<br />+ */<br />+struct _ipath_layer {<br />+ int (*l_intr) (const ipath_type, uint32_t);<br />+ int (*l_rcv) (const ipath_type, void *, struct sk_buff *);<br />+ int (*l_rcv_lid) (const ipath_type, void *);<br />+ uint16_t l_rcv_opcode;<br />+ uint16_t l_rcv_lid_opcode;<br />+};<br />+<br />+/* Verbs layer interface */<br />+struct _verbs_layer {<br />+ int (*l_piobufavail) (const ipath_type);<br />+ void (*l_rcv) (const ipath_type, void *, void *, u32);<br />+ void (*l_timer_cb) (const ipath_type);<br />+ struct timer_list l_timer;<br />+ unsigned l_flags;<br />+};<br />+<br />+/*<br />+ * These are the fields that only exist for port 0, not per port, so<br />+ * they aren't in ipath_devdata<br />+ */<br />+typedef struct _ipath_devdata {<br />+ /* driver data structures */<br />+ /* mem-mapped pointer to base of chip regs */<br />+ volatile uint64_t *ipath_kregbase;<br />+ /* end of mem-mapped chip space; range checking */<br />+ uint64_t *ipath_kregend;<br />+ /* physical address of chip for io_remap, etc. */<br />+ unsigned long ipath_physaddr;<br />+ /* base of memory alloced for ipath_kregbase, for free */<br />+ uint64_t *ipath_kregalloc;<br />+ /*<br />+ * version of kregbase that doesn't have high bits set (for 32 bit<br />+ * programs, so mmap64 44 bit works)<br />+ */<br />+ uint64_t *ipath_kregvirt;<br />+ /* virtual address where port0 rcvhdrqtail updated for this unit */<br />+ volatile uint64_t *ipath_hdrqtailptr;<br />+ ipath_portdata **ipath_pd; /* ipath_cfgports pointers */<br />+ /* sk_buffs used by port 0 eager receive queue */<br />+ struct sk_buff **ipath_port0_skbs;<br />+ /*<br />+ * points to area where PIOavail registers will be DMA'ed. Has to<br />+ * be on a page of it's own, because the page will be mapped into user<br />+ * program space. This copy is *ONLY* ever written by DMA, not by<br />+ * the driver! Need a copy per device when we get to multiple devices<br />+ */<br />+ volatile uint64_t *ipath_pioavailregs_dma;<br />+ /* original address for free */<br />+ volatile uint64_t *__ipath_pioavailregs_base;<br />+ /* physical address where updates occur */<br />+ unsigned long ipath_pioavailregs_phys;<br />+ struct _ipath_layer ipath_layer;<br />+ struct _verbs_layer verbs_layer;<br />+ /* total dwords sent (summed from counter) */<br />+ uint64_t ipath_sword;<br />+ /* total dwords received (summed from counter) */<br />+ uint64_t ipath_rword;<br />+ /* total packets sent (summed from counter) */<br />+ uint64_t ipath_spkts;<br />+ /* total packets received (summed from counter) */<br />+ uint64_t ipath_rpkts;<br />+ /* to make the receive interrupt failsafe */<br />+ uint64_t ipath_lastqtail;<br />+ uint64_t _ipath_status; /* ipath_statusp initially points to this. */<br />+ uint64_t ipath_guid; /* GUID for this interface, in network order */<br />+ /*<br />+ * aggregrate of error bits reported since<br />+ * last cleared, for limiting of error reporting<br />+ */<br />+ uint64_t ipath_lasterror;<br />+ /*<br />+ * aggregrate of error bits reported<br />+ * since last cleared, for limiting of hwerror reporting<br />+ */<br />+ uint64_t ipath_lasthwerror;<br />+ /*<br />+ * errors masked because they occur too fast,<br />+ * also includes errors that are always ignored (ipath_ignorederrs)<br />+ */<br />+ uint64_t ipath_maskederrs;<br />+ /* time at which to re-enable maskederrs */<br />+ cycles_t ipath_unmasktime;<br />+ /*<br />+ * errors always ignored (masked), at least<br />+ * for a given chip/device, because they are wrong or not useful<br />+ */<br />+ uint64_t ipath_ignorederrs;<br />+ /* count of egrfull errors, combined for all ports */<br />+ uint64_t ipath_last_tidfull;<br />+ uint64_t ipath_lastport0rcv_cnt; /* for ipath_qcheck() */<br />+<br />+ uint32_t ipath_kregsize; /* size of memory at ipath_kregbase */<br />+ /* number of registers used for pioavail */<br />+ uint32_t ipath_pioavregs;<br />+ uint32_t ipath_flags; /* IPATH_POLL, etc. */<br />+ /* ipath_flags sma is waiting for */<br />+ uint32_t ipath_sma_state_wanted;<br />+ /* last buffer for user use, first buf for kernel use is this index. */<br />+ uint32_t ipath_lastport_piobuf;<br />+ uint32_t pci_registered; /* driver is a registered pci device */<br />+ uint32_t ipath_stats_timer_active; /* is a stats timer active */<br />+ /* dwords sent read from infinipath counter */<br />+ uint32_t ipath_lastsword;<br />+ /* dwords received read from infinipath counter */<br />+ uint32_t ipath_lastrword;<br />+ /* sent packets read from infinipath counter */<br />+ uint32_t ipath_lastspkts;<br />+ /* received packets read from infinipath counter */<br />+ uint32_t ipath_lastrpkts;<br />+ uint32_t ipath_pbufsport; /* pio bufs allocated per port */<br />+ /*<br />+ * number of ports configured as max; zero is<br />+ * set to number chip supports, less gives more pio bufs/port, etc.<br />+ */<br />+ uint32_t ipath_cfgports;<br />+ /* our idea of the port0 rcvhdrq head offset */<br />+ uint32_t ipath_port0head;<br />+ uint32_t ipath_p0_hdrqfull; /* count of port 0 hdrqfull errors */<br />+<br />+ /*<br />+ * (*cfgports) used to suppress multiple instances of same port<br />+ * staying stuck at same point<br />+ */<br />+ uint32_t *ipath_lastrcvhdrqtails;<br />+ /*<br />+ * (*cfgports) used to suppress multiple instances of same port<br />+ * staying stuck at same point<br />+ */<br />+ uint32_t *ipath_lastegrheads;<br />+ /*<br />+ * index of last piobuffer we used. Speeds up searching, by starting<br />+ * at this point. Doesn't matter if multiple cpu's use and update,<br />+ * last updater is only write that matters. Whenever it wraps,<br />+ * we update shadow copies. Need a copy per device when we get to<br />+ * multiple devices<br />+ */<br />+ uint32_t ipath_lastpioindex;<br />+ uint32_t ipath_freezelen; /* max length of freezemsg */<br />+ uint32_t ipath_consec_nopiobuf; /* consecutive times we wanted a PIO buffer<br />+ * but were unable to get one */<br />+ uint32_t ipath_upd_pio_shadow; /* hint that we should update<br />+ * ipath_pioavailshadow before looking for a PIO buffer */<br />+ uint32_t ipath_nosma_bufs; /* sequential tries for SMA send and no bufs */<br />+ uint32_t ipath_nosma_secs; /* duration (seconds) ipath_nosma_bufs set */<br />+ /* HT/PCI Vendor ID (here for NodeInfo) */<br />+ uint16_t ipath_vendorid;<br />+ /* HT/PCI Device ID (here for NodeInfo) */<br />+ uint16_t ipath_deviceid;<br />+ /* offset in HT config space of slave/primary interface block */<br />+ uint8_t ipath_ht_slave_off;<br />+ int ipath_mtrr; /* registration handle for WRCOMB setting on */<br />+ /* ref count of how many users set each pkey */<br />+ atomic_t ipath_pkeyrefs[4];<br />+ /* shadow copy of all exptids physaddr; used only by funcsim */<br />+ uint64_t *ipath_tidsimshadow;<br />+ /* shadow copy of struct page *'s for exp tid pages */<br />+ struct page **ipath_pageshadow;<br />+ /*<br />+ * IPATH_STATUS_*<br />+ * this address is mapped readonly into user processes so they can<br />+ * get status cheaply, whenever they want.<br />+ */<br />+ uint64_t *ipath_statusp;<br />+ char *ipath_freezemsg; /* freeze msg if hw error put chip in freeze */<br />+ struct pci_dev *pcidev; /* pci access data structure */<br />+ /* timer used to prevent stats overflow, error throttling, etc. */<br />+ struct timer_list ipath_stats_timer;<br />+ /* only allow one interrupt at a time. */<br />+ unsigned long ipath_rcv_pending;<br />+<br />+ /*<br />+ * shadow copies of registers; size indicates read access size<br />+ * Most of them are readonly, but some are write-only register, where<br />+ * we manipulate the bits in the shadow copy, and then write the shadow<br />+ * copy to infinipath<br />+ * We deliberately make most of these 32 bits, since they have<br />+ * restricted range and for any that we read, we won't to generate<br />+ * 32 bit accesses, since Opteron will generate 2 separate 32 bit<br />+ * HT transactions for a 64 bit read, and we want to avoid unnecessary<br />+ * HT transactions<br />+ */<br />+<br />+ /* This is the 64 bit group */<br />+ /*<br />+ * shadow of pioavail, check to be sure it's large enough at<br />+ * init time.<br />+ */<br />+ uint64_t ipath_pioavailshadow[8];<br />+ uint64_t ipath_gpio_out; /* shadow of kr_gpio_out, for rmw ops */<br />+ /* kr_revision value (also see ipath_majrev) */<br />+ uint64_t ipath_revision;<br />+ /* shadow of ibcctrl, for interrupt handling of link changes, etc. */<br />+ uint64_t ipath_ibcctrl;<br />+ /*<br />+ * last ibcstatus, to suppress "duplicate" status change messages,<br />+ * mostly from 2 to 3<br />+ */<br />+ uint64_t ipath_lastibcstat;<br />+ /* mask of hardware errors that are enabled */<br />+ uint64_t ipath_hwerrmask;<br />+ uint64_t ipath_extctrl; /* shadow the gpio output contents */<br />+<br />+ /* these are the "32 bit" regs */<br />+ /*<br />+ * number of GUIDs in the flash for this interface; may need some<br />+ * rethinking for setting on other ifaces<br />+ */<br />+ uint32_t ipath_nguid;<br />+ uint32_t ipath_rcvctrl; /* shadow kr_rcvctrl */<br />+ uint32_t ipath_sendctrl; /* shadow kr_sendctrl */<br />+ uint32_t ipath_rcvhdrcnt; /* value we put in kr_rcvhdrcnt */<br />+ uint32_t ipath_rcvhdrsize; /* value we put in kr_rcvhdrsize */<br />+ uint32_t ipath_rcvhdrentsize; /* value we put in kr_rcvhdrentsize */<br />+ /* byte offset of last entry in rcvhdrq */<br />+ uint32_t ipath_hdrqlast;<br />+ uint32_t ipath_portcnt; /* kr_portcnt value */<br />+ uint32_t ipath_palign; /* kr_pagealign value */<br />+ uint32_t ipath_piobcnt; /* kr_sendpiobufcnt value */<br />+ uint32_t ipath_piobufbase; /* kr_sendpiobufbase value */<br />+ uint32_t ipath_piosize; /* kr_sendpiosize */<br />+ uint32_t ipath_rcvegrbase; /* kr_rcvegrbase value */<br />+ uint32_t ipath_rcvegrcnt; /* kr_rcvegrcnt value */<br />+ uint32_t ipath_rcvtidbase; /* kr_rcvtidbase value */<br />+ uint32_t ipath_rcvtidcnt; /* kr_rcvtidcnt value */<br />+ uint32_t ipath_sregbase; /* kr_sendregbase */<br />+ uint32_t ipath_uregbase; /* kr_userregbase */<br />+ uint32_t ipath_cregbase; /* kr_counterregbase */<br />+ uint32_t ipath_control; /* shadow the control register contents */<br />+ uint32_t ipath_pcirev; /* PCI revision register (HTC rev on FPGA) */<br />+<br />+ uint32_t ipath_ibmtu; /* The MTU programmed for this unit */<br />+ /*<br />+ * The max size IB packet, included IB headers that we can send.<br />+ * Starts same as ipath_piosize, but is affected when ibmtu is<br />+ * changed, or by size of eager buffers<br />+ */<br />+ uint32_t ipath_ibmaxlen;<br />+ /*<br />+ * ibmaxlen at init time, limited by chip and by receive buffer size.<br />+ * Not changed after init.<br />+ */<br />+ uint32_t ipath_init_ibmaxlen;<br />+ /* size we allocate for each rcvegrbuffer */<br />+ uint32_t ipath_rcvegrbufsize;<br />+ uint32_t ipath_htwidth; /* width (2,4,8,16,32) from HT config reg */<br />+ uint32_t ipath_htspeed; /* HT speed (200,400,800,1000) from HT config */<br />+ /* bitmap of ports waiting for PIO avail intr */<br />+ uint32_t ipath_portpiowait;<br />+ /*<br />+ *number of sequential ibcstatus change for polling active/quiet<br />+ * (i.e., link not coming up).<br />+ */<br />+ uint32_t ipath_ibpollcnt;<br />+ uint16_t ipath_mlid; /* MLID programmed for this instance */<br />+ uint16_t ipath_lid; /* LID programmed for this instance */<br />+ /* list of pkeys programmed; 0 means not set */<br />+ uint16_t ipath_pkeys[4];<br />+ uint8_t ipath_serial[12]; /* ASCII serial number, from flash */<br />+ uint8_t ipath_majrev; /* chip major rev, from ipath_revision */<br />+ uint8_t ipath_minrev; /* chip minor rev, from ipath_revision */<br />+ uint8_t ipath_boardrev; /* board rev, from ipath_revision */<br />+ uint8_t ipath_unit; /* Unit number for this chip */<br />+} ipath_devdata;<br />+<br />+/*<br />+ * A segment is a linear region of low physical memory.<br />+ * XXX Maybe we should use phys addr here and kmap()/kunmap()<br />+ * Used by the verbs layer.<br />+ */<br />+struct ipath_seg {<br />+ void *vaddr;<br />+ u64 length;<br />+};<br />+<br />+/* The number of ipath_segs that fit in a page. */<br />+#define IPATH_SEGSZ (PAGE_SIZE / sizeof (struct ipath_seg))<br />+<br />+struct ipath_segarray {<br />+ struct ipath_seg segs[IPATH_SEGSZ];<br />+};<br />+<br />+/*<br />+ * Used by the verbs layer.<br />+ */<br />+struct ipath_mregion {<br />+ u64 user_base; /* User's address for this region */<br />+ u64 iova; /* IB start address of this region */<br />+ size_t length;<br />+ u32 lkey;<br />+ u32 offset; /* offset (bytes) to start of region */<br />+ int access_flags;<br />+ u32 max_segs; /* number of ipath_segs in all the arrays */<br />+ u32 mapsz; /* size of the map array */<br />+ struct ipath_segarray *map[0]; /* the segments */<br />+};<br />+<br />+/*<br />+ * These keep track of the copy progress within a memory region.<br />+ * Used by the verbs layer.<br />+ */<br />+struct ipath_sge {<br />+ struct ipath_mregion *mr;<br />+ void *vaddr; /* current pointer into the segment */<br />+ u32 sge_length; /* length of the SGE */<br />+ u32 length; /* remaining length of the segment */<br />+ u16 m; /* current index: mr-&gt;map[m] */<br />+ u16 n; /* current index: mr-&gt;map[m]-&gt;segs[n] */<br />+};<br />+<br />+struct ipath_sge_state {<br />+ struct ipath_sge *sg_list; /* next SGE to be used if any */<br />+ struct ipath_sge sge; /* progress state for the current SGE */<br />+ u8 num_sge;<br />+};<br />+<br />+extern ipath_devdata devdata[];<br />+#define IPATH_UNIT(p) ((p)-devdata)<br />+extern const uint32_t infinipath_max; /* number of units (chips) supported */<br />+extern const char *ipath_minor_names[];<br />+<br />+extern int ipath_diags_enabled; /* is diags mode enabled? */<br />+<br />+/* clean up any per-chip chip-specific stuff */<br />+void ipath_chip_cleanup(ipath_devdata *);<br />+void ipath_chip_done(void); /* clean up any chip type-specific stuff */<br />+void ipath_handle_hwerrors(const ipath_type, char *, int);<br />+int ipath_validate_rev(ipath_devdata *);<br />+void ipath_clear_init_hwerrs(const ipath_type);<br />+<br />+/*<br />+ * This is here to simplify compatibility with source that supports<br />+ * multiple chip types<br />+ */<br />+void ipath_ht_get_boardname(const ipath_type t, char *name, size_t namelen);<br />+<br />+/* these are primarily for SMA, but are also used by diags */<br />+int ipath_send_smapkt(struct ipath_sendpkt *);<br />+<br />+int ipath_wait_linkstate(const ipath_type, uint32_t, int);<br />+void ipath_down_link(const ipath_type);<br />+void ipath_set_ib_lstate(const ipath_type, int);<br />+void ipath_kreceive(const ipath_type);<br />+int ipath_setrcvhdrsize(const ipath_type, unsigned);<br />+<br />+/* for use in system calls, where we want to know device type, etc. */<br />+#define port_fp(fp) (((fp)-&gt;private_data&gt;(void*)255UL)?((ipath_portdata *)fp-&gt;private_data):NULL)<br />+<br />+/*<br />+ * somebody is waiting in poll (initially<br />+ * used only for simulation notification of register/infinipath memory<br />+ * changes<br />+ */<br />+#define IPATH_POLL 0x1<br />+#define IPATH_INITTED 0x2 /* The chip or simulator is up and initted */<br />+#define IPATH_RCVHDRSZ_SET 0x4 /* set if any user code has set kr_rcvhdrsize */<br />+/* The chip or simulator is present and valid for accesses */<br />+#define IPATH_PRESENT 0x8<br />+/* HT link0 is only 8 bits wide, ignore upper byte crc errors, etc. */<br />+#define IPATH_8BIT_IN_HT0 0x10<br />+/* HT link1 is only 8 bits wide, ignore upper byte crc errors, etc. */<br />+#define IPATH_8BIT_IN_HT1 0x20<br />+/* The link is down (or not yet up 0x11 or earlier) */<br />+#define IPATH_LINKDOWN 0x40<br />+#define IPATH_LINKINIT 0x80 /* The link level is up (0x11) */<br />+/* The link is in the armed (0x21) state */<br />+#define IPATH_LINKARMED 0x100<br />+/* The link is in the active (0x31) state */<br />+#define IPATH_LINKACTIVE 0x200<br />+/* The link was taken down, but no interrupt yet */<br />+#define IPATH_LINKUNK 0x400<br />+/* link being moved to armed (0x21) state */<br />+#define IPATH_LINK_TOARMED 0x800<br />+/* link being moved to active (0x31) state */<br />+#define IPATH_LINK_TOACTIVE 0x1000<br />+/* linkinit cmd is SLEEP, move to POLL */<br />+#define IPATH_LINK_SLEEPING 0x2000<br />+/* no IB cable, or no device on IB cable */<br />+#define IPATH_NOCABLE 0x4000<br />+/* Supports port zero per packet receive interrupts via GPIO */<br />+#define IPATH_GPIO_INTR 0x8000<br />+<br />+/* portdata flag values */<br />+#define IPATH_PORT_WAITING_RCV 0x4 /* waiting for a packet to arrive */<br />+/* waiting for a PIO buffer to be available */<br />+#define IPATH_PORT_WAITING_PIO 0x8<br />+<br />+/*<br />+ * do the chip initialization, either on startup for the real hardware,<br />+ * or via ioctl for simulation.<br />+ */<br />+extern int ipath_init_chip(const ipath_type);<br />+/* free up any allocated data at closes */<br />+extern void ipath_free_data(ipath_portdata * dd);<br />+extern void ipath_init_picotime(void); /* init cycles to picosecs conversion */<br />+extern int ipath_bringup_serdes(const ipath_type);<br />+extern int ipath_waitfor_mdio_cmdready(const ipath_type);<br />+extern int ipath_waitfor_complete(const ipath_type, ipath_kreg, uint64_t,<br />+ uint64_t *);<br />+extern void ipath_quiet_serdes(const ipath_type);<br />+extern void ipath_get_boardname(uint8_t, char *, size_t);<br />+extern int ipath_getpiobuf(int);<br />+extern int ipath_bufavail(int);<br />+extern int ipath_rd_eeprom(const ipath_type port_unit,<br />+ struct ipath_eeprom_req *);<br />+extern uint64_t ipath_snap_cntr(const ipath_type, ipath_creg);<br />+<br />+/*<br />+ * these should be somewhat dynamic someday, although they are fixed<br />+ * for all users of the device on any given load.<br />+ *<br />+ * NOTE: There is a VM bug in the 2.4 Kernels similar to the one Dave<br />+ * fixed in the 2.6 Kernel. When using large or discontinuous memory,<br />+ * we get random kernel oops. So, in 2.4, we are just going to stick<br />+ * with 4k chunks instead of 64k chunks.<br />+ */<br />+/* (words) room for all IB headers and KD proto header */<br />+#define IPATH_RCVHDRENTSIZE 16<br />+/*<br />+ * 64K, which is about all you can hope to get contiguous. API allows<br />+ * users to request a size, for now I'm ignoring that.<br />+ */<br />+#define IPATH_RCVHDRCNT 1024<br />+<br />+/*<br />+ * number of words in KD protocol header if not set by ipath_userinit();<br />+ * this uses the full 64 bytes of rcvhdrentry<br />+ */<br />+#define IPATH_DFLT_RCVHDRSIZE 9<br />+<br />+#define IPATH_MDIO_CMD_WRITE 1<br />+#define IPATH_MDIO_CMD_READ 2<br />+#define IPATH_MDIO_CLD_DIV 25 /* to get 2.5 Mhz mdio clock */<br />+#define IPATH_MDIO_CMDVALID 0x40000000 /* bit 30 */<br />+#define IPATH_MDIO_DATAVALID 0x80000000 /* bit 31 */<br />+#define IPATH_MDIO_CTRL_STD 0x0<br />+<br />+#define IPATH_MDIO_REQ(cmd,dev,reg,data) ( (((uint64_t)IPATH_MDIO_CLD_DIV) &lt;&lt; 32) | \<br />+ ((cmd) &lt;&lt; 26) | ((dev)&lt;&lt;21) | ((reg) &lt;&lt; 16) | ((data) &amp; 0xFFFF))<br />+<br />+#define IPATH_MDIO_CTRL_XGXS_REG_8 0x8 /* signal and fifo status, in bank 31 */<br />+<br />+/* controls loopback, redundancy */<br />+#define IPATH_MDIO_CTRL_8355_REG_1 0x10<br />+#define IPATH_MDIO_CTRL_8355_REG_2 0x11 /* premph, encdec, etc. */<br />+#define IPATH_MDIO_CTRL_8355_REG_6 0x15 /* Kchars, etc. */<br />+#define IPATH_MDIO_CTRL_8355_REG_9 0x18<br />+#define IPATH_MDIO_CTRL_8355_REG_10 0x1D<br />+<br />+/*<br />+ * these function similarly to the mlock/munlock system calls.<br />+ * ipath_mlock() is used to pin an address range (if not already pinned),<br />+ * and optionally return the list of physical addresses<br />+ * ipath_munlock() does the obvious, and ipath_mlock() cleans up all <br />+ * private memory, used at driver unload.<br />+ * ipath_mlock_nocopy() is similar to mlock, but only one page, and marks<br />+ * the vm so the page isn't taken away on a fork.<br />+ */<br />+int ipath_mlock(unsigned long, size_t, struct page **);<br />+int ipath_mlock_nocopy(unsigned long, struct page **);<br />+int ipath_munlock(size_t, struct page **);<br />+void ipath_mlock_cleanup(ipath_portdata *);<br />+int ipath_eeprom_read(const ipath_type, uint8_t, void *, int);<br />+int ipath_eeprom_write(const ipath_type, uint8_t, void *, int);<br />+<br />+/* these are used for the registers that vary with port */<br />+void ipath_kput_kreg_port(const ipath_type, ipath_kreg, unsigned, uint64_t);<br />+uint64_t ipath_kget_kreg64_port(const ipath_type, ipath_kreg, unsigned);<br />+<br />+#define ipath_func_krecord(a)<br />+#define ipath_func_urecord(a, b)<br />+#define ipath_func_mrecord(a, b)<br />+#define ipath_func_rkrecord(a)<br />+#define ipath_func_rurecord(a, b)<br />+#define ipath_func_rmrecord(a, b)<br />+#define ipath_func_rsrecord(a)<br />+#define ipath_func_rcrecord(a)<br />+<br />+/*<br />+ * we could have a single register get/put routine, that takes a group<br />+ * type, but for now I've chosen to have separate routines; I think this<br />+ * is somewhat clearer and cleaner, but we'll see. It also gives us some<br />+ * error checking. 64 bit register reads should always work, but are<br />+ * inefficient on opteron (2 separate HT 32 bit reads), so we use kreg32<br />+ * wherever possible. User register and counter register reads are always<br />+ * 32 bit reads, so only one form of those routines<br />+ */<br />+<br />+/*<br />+ * return contents of a user register group register; not normally<br />+ * used in the kernel, except port 0<br />+ */<br />+static __inline__ uint32_t ipath_kget_ureg32(const ipath_type, ipath_ureg, int)<br />+ __attribute__ ((always_inline));<br />+/* return contents of a kernel register group register */<br />+static __inline__ uint64_t ipath_kget_kreg64(const ipath_type, ipath_kreg)<br />+ __attribute__ ((always_inline));<br />+static __inline__ uint32_t ipath_kget_kreg32(const ipath_type, ipath_kreg)<br />+ __attribute__ ((always_inline));<br />+/* return contents of a counter register group register */<br />+static __inline__ uint32_t ipath_kget_creg32(const ipath_type, ipath_creg)<br />+ __attribute__ ((always_inline));<br />+<br />+/*<br />+ * change contents of a user register group register; not normally<br />+ * used in the kernel, except port 0<br />+ */<br />+static __inline__ void ipath_kput_ureg(const ipath_type, ipath_ureg, uint64_t,<br />+ int) __attribute__ ((always_inline));<br />+/* change contents of a kernel register group register */<br />+static __inline__ void ipath_kput_kreg(const ipath_type, ipath_kreg, uint64_t)<br />+ __attribute__ ((always_inline));<br />+static __inline__ void ipath_kput_memq(const ipath_type, volatile uint64_t *,<br />+ uint64_t)<br />+ __attribute__ ((always_inline));<br />+<br />+#ifdef IPATH_COSIM<br />+extern __u32 sim_readl(const volatile void __iomem * addr);<br />+extern __u64 sim_readq(const volatile void __iomem * addr);<br />+extern void sim_writel(__u32 val, volatile void __iomem * addr);<br />+extern void sim_writeq(__u64 val, volatile void __iomem * addr);<br />+#define ipath_readl(addr) sim_readl(addr)<br />+#define ipath_readq(addr) sim_readq(addr)<br />+#define ipath_writel(val, addr) sim_writel(val, addr)<br />+#define ipath_writeq(val, addr) sim_writeq(val, addr)<br />+#else<br />+#define ipath_readl(addr) readl(addr)<br />+#define ipath_readq(addr) readq(addr)<br />+#define ipath_writel(val, addr) writel(val, addr)<br />+#define ipath_writeq(val, addr) writeq(val, addr)<br />+#endif<br />+<br />+/*<br />+ * At the moment, none of the s-registers are writable, so no ipath_kput_sreg()<br />+ * At the moment, none of the c-registers are writable, so no ipath_kput_creg()<br />+ */<br />+<br />+/*<br />+ * return the contents of a register that is virtualized to be per port<br />+ * prints a debug message and returns ~0ULL on errors (not distinguishable from<br />+ * valid contents at runtime; we may add a separate error variable at some<br />+ * point). Initially, ipath_dev isn't needed because I only have one simulation<br />+ * but that will change soon<br />+ * This is normally not used by the kernel, but may be for debugging,<br />+ * and has a different implementation than user mode, which is why<br />+ * it's not in _common.h<br />+ */<br />+static __inline__ uint32_t ipath_kget_ureg32(const ipath_type stype,<br />+ ipath_ureg regno, int port)<br />+{<br />+ uint64_t *ubase;<br />+<br />+ ubase = (uint64_t *) (devdata[stype].ipath_uregbase<br />+ + (char *)devdata[stype].ipath_kregbase<br />+ + devdata[stype].ipath_palign * port);<br />+ return ubase ? ipath_readl(ubase + regno) : 0;<br />+}<br />+<br />+/*<br />+ * change the contents of a register that is virtualized to be per port<br />+ * prints a debug message and returns 1 on errors, 0 on success.<br />+ * Initially, ipath_dev isn't needed because I only have one simulation<br />+ * but that will change soon<br />+ */<br />+static __inline__ void ipath_kput_ureg(const ipath_type stype, ipath_ureg regno,<br />+ uint64_t value, int port)<br />+{<br />+ uint64_t *ubase;<br />+<br />+ ubase = (uint64_t *) (devdata[stype].ipath_uregbase<br />+ + (char *)devdata[stype].ipath_kregbase<br />+ + devdata[stype].ipath_palign * port);<br />+ if (ubase)<br />+ ipath_writeq(value, &amp;ubase[regno]);<br />+}<br />+<br />+static __inline__ uint32_t ipath_kget_kreg32(const ipath_type stype,<br />+ ipath_kreg regno)<br />+{<br />+ volatile uint32_t *kreg32;<br />+<br />+ if (!devdata[stype].ipath_kregbase)<br />+ return ~0;<br />+<br />+ kreg32 = (volatile uint32_t *)&amp;devdata[stype].ipath_kregbase[regno];<br />+ return ipath_readl(kreg32);<br />+}<br />+<br />+static __inline__ uint64_t ipath_kget_kreg64(const ipath_type stype,<br />+ ipath_kreg regno)<br />+{<br />+ if (!devdata[stype].ipath_kregbase)<br />+ return ~0ULL;<br />+<br />+ return ipath_readq(&amp;devdata[stype].ipath_kregbase[regno]);<br />+}<br />+<br />+static __inline__ void ipath_kput_kreg(const ipath_type stype,<br />+ ipath_kreg regno, uint64_t value)<br />+{<br />+ if (devdata[stype].ipath_kregbase)<br />+ ipath_writeq(value, &amp;devdata[stype].ipath_kregbase[regno]);<br />+}<br />+<br />+static __inline__ uint32_t ipath_kget_creg32(const ipath_type stype,<br />+ ipath_sreg regno)<br />+{<br />+ uint64_t *cbase;<br />+<br />+ cbase = (uint64_t *) (devdata[stype].ipath_cregbase<br />+ + (char *)devdata[stype].ipath_kregbase);<br />+ return cbase ? ipath_readl(cbase + regno) : 0;<br />+}<br />+<br />+/*<br />+ * caddr is the destination chip address (full pointer, not offset),<br />+ * val is the qword to write there. We only handle a single qword (8 bytes).<br />+ * This is not used for copies to the PIO buffer, just TID updates, etc.<br />+ * This function is needed for simulation, and also localizes all chip<br />+ * mem writes for better/simpler debugging.<br />+ */<br />+static __inline__ void ipath_kput_memq(const ipath_type stype,<br />+ volatile uint64_t * caddr, uint64_t val)<br />+{<br />+ if (devdata[stype].ipath_kregbase)<br />+ ipath_writeq(val, caddr);<br />+}<br />+<br />+#endif /* _IPATH_KERNEL_H */<br />diff --git a/drivers/infiniband/hw/ipath/ipath_layer.h b/drivers/infiniband/hw/ipath/ipath_layer.h<br />new file mode 100644<br />index 0000000..3b7954d<br />--- /dev/null<br />+++ b/drivers/infiniband/hw/ipath/ipath_layer.h<br />&#64;&#64; -0,0 +1,131 &#64;&#64;<br />+/*<br />+ * Copyright (c) 2003, 2004, 2005. PathScale, Inc. All rights reserved.<br />+ *<br />+ * This software is available to you under a choice of one of two<br />+ * licenses. You may choose to be licensed under the terms of the GNU<br />+ * General Public License (GPL) Version 2, available from the file<br />+ * COPYING in the main directory of this source tree, or the<br />+ * OpenIB.org BSD license below:<br />+ *<br />+ * Redistribution and use in source and binary forms, with or<br />+ * without modification, are permitted provided that the following<br />+ * conditions are met:<br />+ *<br />+ * - Redistributions of source code must retain the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer.<br />+ *<br />+ * - Redistributions in binary form must reproduce the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer in the documentation and/or other materials<br />+ * provided with the distribution.<br />+ *<br />+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br />+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br />+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br />+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS<br />+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br />+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br />+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />+ * SOFTWARE.<br />+ *<br />+ * Patent licenses, if any, provided herein do not apply to<br />+ * combinations of this program with other software, or any other<br />+ * product whatsoever.<br />+ *<br />+ * $Id: ipath_layer.h 4365 2005-12-10 00:04:16Z rjwalsh $<br />+ */<br />+<br />+#ifndef _IPATH_LAYER_H<br />+#define _IPATH_LAYER_H<br />+<br />+/*<br />+ * This header file is for symbols shared between the infinipath driver<br />+ * and drivers layered upon it (such as ipath).<br />+ */<br />+<br />+struct sk_buff;<br />+struct ipath_sge_state;<br />+<br />+struct ipath_layer_counters {<br />+ uint64_t symbol_error_counter;<br />+ uint64_t link_error_recovery_counter;<br />+ uint64_t link_downed_counter;<br />+ uint64_t port_rcv_errors;<br />+ uint64_t port_rcv_remphys_errors;<br />+ uint64_t port_xmit_discards;<br />+ uint64_t port_xmit_data;<br />+ uint64_t port_rcv_data;<br />+ uint64_t port_xmit_packets;<br />+ uint64_t port_rcv_packets;<br />+};<br />+<br />+extern int ipath_layer_register(const ipath_type device,<br />+ int (*l_intr) (const ipath_type, uint32_t),<br />+ int (*l_rcv) (const ipath_type, void *,<br />+ struct sk_buff *),<br />+ uint16_t rcv_opcode,<br />+ int (*l_rcv_lid) (const ipath_type, void *),<br />+ uint16_t rcv_lid_opcode);<br />+extern int ipath_verbs_register(const ipath_type device,<br />+ int (*l_piobufavail) (const ipath_type device),<br />+ void (*l_rcv) (const ipath_type device,<br />+ void *rhdr, void *data,<br />+ u32 tlen),<br />+ void (*l_timer_cb) (const ipath_type device));<br />+extern void ipath_verbs_unregister(const ipath_type device);<br />+extern int ipath_layer_open(const ipath_type device, uint32_t * pktmax);<br />+extern int16_t ipath_layer_get_lid(const ipath_type device);<br />+extern int ipath_layer_get_mac(const ipath_type device, uint8_t *);<br />+extern int16_t ipath_layer_get_bcast(const ipath_type device);<br />+extern int ipath_layer_get_num_of_dev(void);<br />+extern int ipath_layer_get_cr_errpkey(const ipath_type device);<br />+extern int ipath_kset_linkstate(uint32_t arg);<br />+extern int ipath_kset_mtu(uint32_t);<br />+extern void ipath_set_sps_lid(const ipath_type, uint32_t);<br />+extern void ipath_layer_close(const ipath_type device);<br />+extern int ipath_layer_send(const ipath_type device, void *hdr, void *data,<br />+ uint32_t datalen);<br />+extern int ipath_verbs_send(const ipath_type device, uint32_t hdrwords,<br />+ uint32_t *hdr, uint32_t len,<br />+ struct ipath_sge_state *ss);<br />+extern int ipath_layer_send_skb(struct copy_data_s *cdata);<br />+extern void ipath_layer_set_piointbufavail_int(const ipath_type device);<br />+extern void ipath_get_boardname(const ipath_type, char *name, size_t namelen);<br />+extern void ipath_layer_snapshot_counters(const ipath_type t, u64 * swords,<br />+ u64 * rwords, u64 * spkts,<br />+ u64 * rpkts);<br />+extern void ipath_layer_get_counters(const ipath_type device,<br />+ struct ipath_layer_counters *cntrs);<br />+extern void ipath_layer_want_buffer(const ipath_type t);<br />+extern int ipath_layer_set_guid(const ipath_type t, uint64_t guid);<br />+extern uint64_t ipath_layer_get_guid(const ipath_type t);<br />+extern uint32_t ipath_layer_get_nguid(const ipath_type t);<br />+extern int ipath_layer_query_device(const ipath_type t, uint32_t * vendor,<br />+ uint32_t * boardrev, uint32_t * majrev,<br />+ uint32_t * minrev);<br />+extern uint32_t ipath_layer_get_flags(const ipath_type t);<br />+extern struct device *ipath_layer_get_pcidev(const ipath_type t);<br />+extern uint16_t ipath_layer_get_deviceid(const ipath_type t);<br />+extern uint64_t ipath_layer_get_lastibcstat(const ipath_type t);<br />+extern uint32_t ipath_layer_get_ibmtu(const ipath_type t);<br />+extern void ipath_layer_enable_timer(const ipath_type t);<br />+extern void ipath_layer_disable_timer(const ipath_type t);<br />+extern unsigned ipath_verbs_get_flags(const ipath_type device);<br />+extern void ipath_verbs_set_flags(const ipath_type device, unsigned flags);<br />+extern unsigned ipath_layer_get_npkeys(const ipath_type device);<br />+extern unsigned ipath_layer_get_pkey(const ipath_type device, unsigned index);<br />+extern void ipath_layer_get_pkeys(const ipath_type device, uint16_t *pkeys);<br />+extern int ipath_layer_set_pkeys(const ipath_type device, uint16_t *pkeys);<br />+<br />+/* ipath_ether interrupt values */<br />+#define IPATH_LAYER_INT_IF_UP 0x2<br />+#define IPATH_LAYER_INT_IF_DOWN 0x4<br />+#define IPATH_LAYER_INT_LID 0x8<br />+#define IPATH_LAYER_INT_SEND_CONTINUE 0x10<br />+#define IPATH_LAYER_INT_BCAST 0x40<br />+<br />+/* _verbs_layer.l_flags */<br />+#define IPATH_VERBS_KERNEL_SMA 0x1<br />+<br />+#endif /* _IPATH_LAYER_H */<br />diff --git a/drivers/infiniband/hw/ipath/ipath_registers.h b/drivers/infiniband/hw/ipath/ipath_registers.h<br />new file mode 100644<br />index 0000000..6bf0c8b<br />--- /dev/null<br />+++ b/drivers/infiniband/hw/ipath/ipath_registers.h<br />&#64;&#64; -0,0 +1,359 &#64;&#64;<br />+/*<br />+ * Copyright (c) 2003, 2004, 2005. PathScale, Inc. All rights reserved.<br />+ *<br />+ * This software is available to you under a choice of one of two<br />+ * licenses. You may choose to be licensed under the terms of the GNU<br />+ * General Public License (GPL) Version 2, available from the file<br />+ * COPYING in the main directory of this source tree, or the<br />+ * OpenIB.org BSD license below:<br />+ *<br />+ * Redistribution and use in source and binary forms, with or<br />+ * without modification, are permitted provided that the following<br />+ * conditions are met:<br />+ *<br />+ * - Redistributions of source code must retain the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer.<br />+ *<br />+ * - Redistributions in binary form must reproduce the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer in the documentation and/or other materials<br />+ * provided with the distribution.<br />+ *<br />+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br />+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br />+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br />+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS<br />+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br />+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br />+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />+ * SOFTWARE.<br />+ *<br />+ * Patent licenses, if any, provided herein do not apply to<br />+ * combinations of this program with other software, or any other<br />+ * product whatsoever.<br />+ *<br />+ * $Id: ipath_registers.h 4365 2005-12-10 00:04:16Z rjwalsh $<br />+ */<br />+<br />+#ifndef _IPATH_REGISTERS_H<br />+#define _IPATH_REGISTERS_H<br />+<br />+/*<br />+ * This file should only be included by kernel source, and by the diags.<br />+ * It defines the registers, and their contents, for the InfiniPath HT-400 chip<br />+ */<br />+<br />+/*<br />+ * These are the InfiniPath register and buffer bit definitions,<br />+ * that are visible to software, and needed only by the kernel<br />+ * and diag code. A few, that are visible to protocol and user<br />+ * code are in ipath_common.h. Some bits are specific<br />+ * to a given chip implementation, and have been moved to the<br />+ * chip-specific source file<br />+ */<br />+<br />+/* kr_revision bits */<br />+#define INFINIPATH_R_CHIPREVMINOR_MASK 0xFF<br />+#define INFINIPATH_R_CHIPREVMINOR_SHIFT 0<br />+#define INFINIPATH_R_CHIPREVMAJOR_MASK 0xFF<br />+#define INFINIPATH_R_CHIPREVMAJOR_SHIFT 8<br />+#define INFINIPATH_R_ARCH_MASK 0xFF<br />+#define INFINIPATH_R_ARCH_SHIFT 16<br />+#define INFINIPATH_R_SOFTWARE_MASK 0xFF<br />+#define INFINIPATH_R_SOFTWARE_SHIFT 24<br />+#define INFINIPATH_R_BOARDID_MASK 0xFF<br />+#define INFINIPATH_R_BOARDID_SHIFT 32<br />+#define INFINIPATH_R_SIMULATOR 0x8000000000000000ULL<br />+<br />+/* kr_ontrol bits */<br />+#define INFINIPATH_C_FREEZEMODE 0x00000002<br />+#define INFINIPATH_C_LINKENABLE 0x00000004<br />+<br />+/* kr_sendctrl bits */<br />+#define INFINIPATH_S_DISARMPIOBUF_SHIFT 16<br />+#define INFINIPATH_S_ABORT 0x00000001U<br />+#define INFINIPATH_S_PIOINTBUFAVAIL 0x00000002U<br />+#define INFINIPATH_S_PIOBUFAVAILUPD 0x00000004U<br />+#define INFINIPATH_S_PIOENABLE 0x00000008U<br />+#define INFINIPATH_S_DISARM 0x80000000U<br />+<br />+/* kr_rcvctrl bits */<br />+#define INFINIPATH_R_PORTENABLE_SHIFT 0<br />+#define INFINIPATH_R_INTRAVAIL_SHIFT 16<br />+#define INFINIPATH_R_TAILUPD 0x80000000<br />+<br />+/* kr_intstatus, kr_intclear, kr_intmask bits */<br />+#define INFINIPATH_I_RCVURG_SHIFT 0<br />+#define INFINIPATH_I_RCVAVAIL_SHIFT 12<br />+#define INFINIPATH_I_ERROR 0x80000000<br />+#define INFINIPATH_I_SPIOSENT 0x40000000<br />+#define INFINIPATH_I_SPIOBUFAVAIL 0x20000000<br />+#define INFINIPATH_I_GPIO 0x10000000<br />+<br />+/* kr_errorstatus, kr_errorclear, kr_errormask bits */<br />+#define INFINIPATH_E_RFORMATERR 0x0000000000000001ULL<br />+#define INFINIPATH_E_RVCRC 0x0000000000000002ULL<br />+#define INFINIPATH_E_RICRC 0x0000000000000004ULL<br />+#define INFINIPATH_E_RMINPKTLEN 0x0000000000000008ULL<br />+#define INFINIPATH_E_RMAXPKTLEN 0x0000000000000010ULL<br />+#define INFINIPATH_E_RLONGPKTLEN 0x0000000000000020ULL<br />+#define INFINIPATH_E_RSHORTPKTLEN 0x0000000000000040ULL<br />+#define INFINIPATH_E_RUNEXPCHAR 0x0000000000000080ULL<br />+#define INFINIPATH_E_RUNSUPVL 0x0000000000000100ULL<br />+#define INFINIPATH_E_REBP 0x0000000000000200ULL<br />+#define INFINIPATH_E_RIBFLOW 0x0000000000000400ULL<br />+#define INFINIPATH_E_RBADVERSION 0x0000000000000800ULL<br />+#define INFINIPATH_E_RRCVEGRFULL 0x0000000000001000ULL<br />+#define INFINIPATH_E_RRCVHDRFULL 0x0000000000002000ULL<br />+#define INFINIPATH_E_RBADTID 0x0000000000004000ULL<br />+#define INFINIPATH_E_RHDRLEN 0x0000000000008000ULL<br />+#define INFINIPATH_E_RHDR 0x0000000000010000ULL<br />+#define INFINIPATH_E_RIBLOSTLINK 0x0000000000020000ULL<br />+#define INFINIPATH_E_SMINPKTLEN 0x0000000020000000ULL<br />+#define INFINIPATH_E_SMAXPKTLEN 0x0000000040000000ULL<br />+#define INFINIPATH_E_SUNDERRUN 0x0000000080000000ULL<br />+#define INFINIPATH_E_SPKTLEN 0x0000000100000000ULL<br />+#define INFINIPATH_E_SDROPPEDSMPPKT 0x0000000200000000ULL<br />+#define INFINIPATH_E_SDROPPEDDATAPKT 0x0000000400000000ULL<br />+#define INFINIPATH_E_SPIOARMLAUNCH 0x0000000800000000ULL<br />+#define INFINIPATH_E_SUNEXPERRPKTNUM 0x0000001000000000ULL<br />+#define INFINIPATH_E_SUNSUPVL 0x0000002000000000ULL<br />+#define INFINIPATH_E_IBSTATUSCHANGED 0x0001000000000000ULL<br />+#define INFINIPATH_E_INVALIDADDR 0x0002000000000000ULL<br />+#define INFINIPATH_E_RESET 0x0004000000000000ULL<br />+#define INFINIPATH_E_HARDWARE 0x0008000000000000ULL<br />+<br />+/* kr_hwerrclear, kr_hwerrmask, kr_hwerrstatus, bits */<br />+#define INFINIPATH_HWE_HTCMEMPARITYERR_SHIFT 0<br />+#define INFINIPATH_HWE_TXEMEMPARITYERR_MASK 0xFULL<br />+#define INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT 40<br />+#define INFINIPATH_HWE_RXEMEMPARITYERR_MASK 0x7FULL<br />+#define INFINIPATH_HWE_RXEMEMPARITYERR_SHIFT 44<br />+#define INFINIPATH_HWE_HTCBUSTREQPARITYERR 0x0000000080000000ULL<br />+#define INFINIPATH_HWE_HTCBUSTRESPPARITYERR 0x0000000100000000ULL<br />+#define INFINIPATH_HWE_HTCBUSIREQPARITYERR 0x0000000200000000ULL<br />+#define INFINIPATH_HWE_RXDSYNCMEMPARITYERR 0x0000000400000000ULL<br />+#define INFINIPATH_HWE_SERDESPLLFAILED 0x2000000000000000ULL<br />+#define INFINIPATH_HWE_IBCBUSTOSPCPARITYERR 0x4000000000000000ULL<br />+#define INFINIPATH_HWE_IBCBUSFRSPCPARITYERR 0x8000000000000000ULL<br />+<br />+/* kr_hwdiagctrl bits */<br />+#define INFINIPATH_DC_FORCEHTCENABLE 0x20<br />+#define INFINIPATH_DC_FORCEHTCMEMPARITYERR_MASK 0x3FULL<br />+#define INFINIPATH_DC_FORCEHTCMEMPARITYERR_SHIFT 0<br />+#define INFINIPATH_DC_FORCETXEMEMPARITYERR_MASK 0xFULL<br />+#define INFINIPATH_DC_FORCETXEMEMPARITYERR_SHIFT 40<br />+#define INFINIPATH_DC_FORCERXEMEMPARITYERR_MASK 0x7FULL<br />+#define INFINIPATH_DC_FORCERXEMEMPARITYERR_SHIFT 44<br />+#define INFINIPATH_DC_FORCEHTCBUSTREQPARITYERR 0x0000000080000000ULL<br />+#define INFINIPATH_DC_FORCEHTCBUSTRESPPARITYERR 0x0000000100000000ULL<br />+#define INFINIPATH_DC_FORCEHTCBUSIREQPARITYERR 0x0000000200000000ULL<br />+#define INFINIPATH_DC_FORCERXDSYNCMEMPARITYERR 0x0000000400000000ULL<br />+#define INFINIPATH_DC_COUNTERDISABLE 0x1000000000000000ULL<br />+#define INFINIPATH_DC_COUNTERWREN 0x2000000000000000ULL<br />+#define INFINIPATH_DC_FORCEIBCBUSTOSPCPARITYERR 0x4000000000000000ULL<br />+#define INFINIPATH_DC_FORCEIBCBUSFRSPCPARITYERR 0x8000000000000000ULL<br />+<br />+/* kr_ibcctrl bits */<br />+#define INFINIPATH_IBCC_FLOWCTRLPERIOD_MASK 0xFFULL<br />+#define INFINIPATH_IBCC_FLOWCTRLPERIOD_SHIFT 0<br />+#define INFINIPATH_IBCC_FLOWCTRLWATERMARK_MASK 0xFFULL<br />+#define INFINIPATH_IBCC_FLOWCTRLWATERMARK_SHIFT 8<br />+#define INFINIPATH_IBCC_LINKINITCMD_MASK 0x3ULL<br />+#define INFINIPATH_IBCC_LINKINITCMD_DISABLE 1<br />+/* cycle through TS1/TS2 till OK */<br />+#define INFINIPATH_IBCC_LINKINITCMD_POLL 2<br />+#define INFINIPATH_IBCC_LINKINITCMD_SLEEP 3 /* wait for TS1, then go on */<br />+#define INFINIPATH_IBCC_LINKINITCMD_SHIFT 16<br />+#define INFINIPATH_IBCC_LINKCMD_MASK 0x3ULL<br />+#define INFINIPATH_IBCC_LINKCMD_INIT 1 /* move to 0x11 */<br />+#define INFINIPATH_IBCC_LINKCMD_ARMED 2 /* move to 0x21 */<br />+#define INFINIPATH_IBCC_LINKCMD_ACTIVE 3 /* move to 0x31 */<br />+#define INFINIPATH_IBCC_LINKCMD_SHIFT 18<br />+#define INFINIPATH_IBCC_MAXPKTLEN_MASK 0x7FFULL<br />+#define INFINIPATH_IBCC_MAXPKTLEN_SHIFT 20<br />+#define INFINIPATH_IBCC_PHYERRTHRESHOLD_MASK 0xFULL<br />+#define INFINIPATH_IBCC_PHYERRTHRESHOLD_SHIFT 32<br />+#define INFINIPATH_IBCC_OVERRUNTHRESHOLD_MASK 0xFULL<br />+#define INFINIPATH_IBCC_OVERRUNTHRESHOLD_SHIFT 36<br />+#define INFINIPATH_IBCC_CREDITSCALE_MASK 0x7ULL<br />+#define INFINIPATH_IBCC_CREDITSCALE_SHIFT 40<br />+#define INFINIPATH_IBCC_LOOPBACK 0x8000000000000000ULL<br />+#define INFINIPATH_IBCC_LINKDOWNDEFAULTSTATE 0x4000000000000000ULL<br />+<br />+/* kr_ibcstatus bits */<br />+#define INFINIPATH_IBCS_LINKTRAININGSTATE_MASK 0xF<br />+#define INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT 0<br />+#define INFINIPATH_IBCS_LINKSTATE_MASK 0x7<br />+#define INFINIPATH_IBCS_LINKSTATE_SHIFT 4<br />+#define INFINIPATH_IBCS_TXREADY 0x40000000<br />+#define INFINIPATH_IBCS_TXCREDITOK 0x80000000<br />+<br />+/* kr_extstatus bits */<br />+#define INFINIPATH_EXTS_SERDESPLLLOCK 0x1<br />+#define INFINIPATH_EXTS_GPIOIN_MASK 0xFFFFULL<br />+#define INFINIPATH_EXTS_GPIOIN_SHIFT 48<br />+<br />+/* kr_extctrl bits */<br />+#define INFINIPATH_EXTC_GPIOINVERT_MASK 0xFFFFULL<br />+#define INFINIPATH_EXTC_GPIOINVERT_SHIFT 32<br />+#define INFINIPATH_EXTC_GPIOOE_MASK 0xFFFFULL<br />+#define INFINIPATH_EXTC_GPIOOE_SHIFT 48<br />+#define INFINIPATH_EXTC_SERDESENABLE 0x80000000ULL<br />+#define INFINIPATH_EXTC_SERDESCONNECT 0x40000000ULL<br />+#define INFINIPATH_EXTC_SERDESENTRUNKING 0x20000000ULL<br />+#define INFINIPATH_EXTC_SERDESDISRXFIFO 0x10000000ULL<br />+#define INFINIPATH_EXTC_SERDESENPLPBK1 0x08000000ULL<br />+#define INFINIPATH_EXTC_SERDESENPLPBK2 0x04000000ULL<br />+#define INFINIPATH_EXTC_SERDESENENCDEC 0x02000000ULL<br />+#define INFINIPATH_EXTC_LEDSECPORTGREENON 0x00000020ULL<br />+#define INFINIPATH_EXTC_LEDSECPORTYELLOWON 0x00000010ULL<br />+#define INFINIPATH_EXTC_LEDPRIPORTGREENON 0x00000008ULL<br />+#define INFINIPATH_EXTC_LEDPRIPORTYELLOWON 0x00000004ULL<br />+#define INFINIPATH_EXTC_LEDGBLOKGREENON 0x00000002ULL<br />+#define INFINIPATH_EXTC_LEDGBLERRREDOFF 0x00000001ULL<br />+<br />+/* kr_mdio bits */<br />+#define INFINIPATH_MDIO_CLKDIV_MASK 0x7FULL<br />+#define INFINIPATH_MDIO_CLKDIV_SHIFT 32<br />+#define INFINIPATH_MDIO_COMMAND_MASK 0x7ULL<br />+#define INFINIPATH_MDIO_COMMAND_SHIFT 26<br />+#define INFINIPATH_MDIO_DEVADDR_MASK 0x1FULL<br />+#define INFINIPATH_MDIO_DEVADDR_SHIFT 21<br />+#define INFINIPATH_MDIO_REGADDR_MASK 0x1FULL<br />+#define INFINIPATH_MDIO_REGADDR_SHIFT 16<br />+#define INFINIPATH_MDIO_DATA_MASK 0xFFFFULL<br />+#define INFINIPATH_MDIO_DATA_SHIFT 0<br />+#define INFINIPATH_MDIO_CMDVALID 0x0000000040000000ULL<br />+#define INFINIPATH_MDIO_RDDATAVALID 0x0000000080000000ULL<br />+<br />+/* kr_partitionkey bits */<br />+#define INFINIPATH_PKEY_SIZE 16<br />+#define INFINIPATH_PKEY_MASK 0xFFFF<br />+#define INFINIPATH_PKEY_DEFAULT_PKEY 0xFFFF<br />+<br />+/* kr_serdesconfig0 bits */<br />+#define INFINIPATH_SERDC0_RESET_MASK 0xfULL /* overal reset bits */<br />+#define INFINIPATH_SERDC0_RESET_PLL 0x10000000ULL /* pll reset */<br />+#define INFINIPATH_SERDC0_TXIDLE 0xF000ULL /* tx idle enables (per lane) */<br />+<br />+/* kr_xgxsconfig bits */<br />+#define INFINIPATH_XGXS_RESET 0x7ULL<br />+#define INFINIPATH_XGXS_MDIOADDR_MASK 0xfULL<br />+#define INFINIPATH_XGXS_MDIOADDR_SHIFT 4<br />+<br />+/* TID entries (memory) */<br />+#define INFINIPATH_RT_VALID 0x8000000000000000ULL<br />+#define INFINIPATH_RT_ADDR_MASK 0xFFFFFFFFFFULL<br />+#define INFINIPATH_RT_ADDR_SHIFT 0<br />+#define INFINIPATH_RT_BUFSIZE_MASK 0x3FFF<br />+#define INFINIPATH_RT_BUFSIZE_SHIFT 48<br />+<br />+/* mask of defined bits for various registers */<br />+extern const uint64_t infinipath_c_bitsextant,<br />+ infinipath_s_bitsextant, infinipath_r_bitsextant,<br />+ infinipath_i_bitsextant, infinipath_e_bitsextant,<br />+ infinipath_hwe_bitsextant, infinipath_dc_bitsextant,<br />+ infinipath_extc_bitsextant, infinipath_mdio_bitsextant,<br />+ infinipath_ibcs_bitsextant, infinipath_ibcc_bitsextant;<br />+<br />+/* masks that are different in different chips */<br />+extern const uint32_t infinipath_i_rcvavail_mask, infinipath_i_rcvurg_mask;<br />+extern const uint64_t infinipath_hwe_htcmemparityerr_mask;<br />+extern const uint64_t infinipath_hwe_spibdcmlockfailed_mask;<br />+extern const uint64_t infinipath_hwe_sphtdcmlockfailed_mask;<br />+extern const uint64_t infinipath_hwe_htcdcmlockfailed_mask;<br />+extern const uint64_t infinipath_hwe_htcdcmlockfailed_shift;<br />+extern const uint64_t infinipath_hwe_sphtdcmlockfailed_shift;<br />+extern const uint64_t infinipath_hwe_spibdcmlockfailed_shift;<br />+<br />+extern const uint64_t infinipath_hwe_htclnkabyte0crcerr;<br />+extern const uint64_t infinipath_hwe_htclnkabyte1crcerr;<br />+extern const uint64_t infinipath_hwe_htclnkbbyte0crcerr;<br />+extern const uint64_t infinipath_hwe_htclnkbbyte1crcerr;<br />+<br />+/*<br />+ * These are the infinipath general register numbers (not offsets).<br />+ * The kernel registers are used directly, those beyond the kernel<br />+ * registers are calculated from one of the base registers. The use of<br />+ * an integer type doesn't allow type-checking as thorough as, say,<br />+ * an enum but allows for better hiding of chip differences.<br />+ */<br />+typedef const uint16_t<br />+ ipath_kreg, /* kernel-only, infinipath general registers */<br />+ ipath_creg, /* kernel-only, infinipath counter registers */<br />+ ipath_sreg; /* kernel-only, infinipath send registers */<br />+<br />+/*<br />+ * These are all implemented such that 64 bit accesses work.<br />+ * Some implement no more than 32 bits. Because 64 bit reads<br />+ * require 2 HT cmds on opteron, we access those with 32 bit<br />+ * reads for efficiency (they are written as 64 bits, since<br />+ * the extra 32 bits are nearly free on writes, and it slightly reduces<br />+ * complexity). The rest are all accessed as 64 bits.<br />+ */<br />+extern ipath_kreg<br />+ /* These are the 32 bit group */<br />+ kr_control, kr_counterregbase, kr_intmask, kr_intstatus,<br />+ kr_pagealign, kr_portcnt, kr_rcvtidbase, kr_rcvtidcnt,<br />+ kr_rcvegrbase, kr_rcvegrcnt, kr_scratch, kr_sendctrl,<br />+ kr_sendpiobufbase, kr_sendpiobufcnt, kr_sendpiosize,<br />+ kr_sendregbase, kr_userregbase,<br />+ /* These are the 64 bit group */<br />+ kr_debugport, kr_debugportselect, kr_errorclear, kr_errormask,<br />+ kr_errorstatus, kr_extctrl, kr_extstatus, kr_gpio_clear, kr_gpio_mask,<br />+ kr_gpio_out, kr_gpio_status, kr_hwdiagctrl, kr_hwerrclear,<br />+ kr_hwerrmask, kr_hwerrstatus, kr_ibcctrl, kr_ibcstatus, kr_intblocked,<br />+ kr_intclear, kr_interruptconfig, kr_mdio, kr_partitionkey, kr_rcvbthqp,<br />+ kr_rcvbufbase, kr_rcvbufsize, kr_rcvctrl, kr_rcvhdrcnt,<br />+ kr_rcvhdrentsize, kr_rcvhdrsize, kr_rcvintmembase, kr_rcvintmemsize,<br />+ kr_revision, kr_sendbuffererror, kr_sendbuffererror1,<br />+ kr_sendbuffererror2, kr_sendbuffererror3, kr_sendpioavailaddr,<br />+ kr_serdesconfig0, kr_serdesconfig1, kr_serdesstatus, kr_txintmembase,<br />+ kr_txintmemsize, kr_xgxsconfig, kr_sync, kr_dump,<br />+ kr_simver, /* simulator only */<br />+ __kr_invalid, /* a marker for debug, don't use them directly */<br />+ /* a marker for debug, don't use them directly */<br />+ __kr_lastvaliddirect,<br />+ /* use only with ipath_k*_kreg64_port(), not *kreg64() */<br />+ kr_rcvhdraddr,<br />+ /* use only with ipath_k*_kreg64_port(), not *kreg64() */<br />+ kr_rcvhdrtailaddr,<br />+ /* we define the full set for the diags, the kernel doesn't use them */<br />+ kr_rcvhdraddr1, kr_rcvhdraddr2, kr_rcvhdraddr3, kr_rcvhdraddr4,<br />+ kr_rcvhdraddr5, kr_rcvhdraddr6, kr_rcvhdraddr7, kr_rcvhdraddr8,<br />+ kr_rcvhdrtailaddr1, kr_rcvhdrtailaddr2, kr_rcvhdrtailaddr3,<br />+ kr_rcvhdrtailaddr4, kr_rcvhdrtailaddr5, kr_rcvhdrtailaddr6,<br />+ kr_rcvhdrtailaddr7, kr_rcvhdrtailaddr8;<br />+<br />+/*<br />+ * first of the pioavail registers, the total number is<br />+ * (kr_sendpiobufcnt / 32); each buffer uses 2 bits<br />+ */<br />+extern ipath_sreg sr_sendpioavail;<br />+<br />+extern ipath_creg cr_badformatcnt, cr_erricrccnt, cr_errlinkcnt,<br />+ cr_errlpcrccnt, cr_errpkey, cr_errrcvflowctrlcnt,<br />+ cr_err_rlencnt, cr_errslencnt, cr_errtidfull,<br />+ cr_errtidvalid, cr_errvcrccnt, cr_ibstatuschange,<br />+ cr_intcnt, cr_invalidrlencnt, cr_invalidslencnt,<br />+ cr_lbflowstallcnt, cr_iblinkdowncnt, cr_iblinkerrrecovcnt,<br />+ cr_ibsymbolerrcnt, cr_pktrcvcnt, cr_pktrcvflowctrlcnt,<br />+ cr_pktsendcnt, cr_pktsendflowcnt, cr_portovflcnt,<br />+ cr_portovflcnt1, cr_portovflcnt2, cr_portovflcnt3, cr_portovflcnt4,<br />+ cr_portovflcnt5, cr_portovflcnt6, cr_portovflcnt7, cr_portovflcnt8,<br />+ cr_rcvebpcnt, cr_rcvovflcnt, cr_rxdroppktcnt,<br />+ cr_senddropped, cr_sendstallcnt, cr_sendunderruncnt,<br />+ cr_unsupvlcnt, cr_wordrcvcnt, cr_wordsendcnt;<br />+<br />+/*<br />+ * register bits for selecting i2c direction and values, used for I2C serial<br />+ * flash<br />+ */<br />+extern const uint16_t ipath_gpio_sda_num;<br />+extern const uint16_t ipath_gpio_scl_num;<br />+extern const uint64_t ipath_gpio_sda;<br />+extern const uint64_t ipath_gpio_scl;<br />+<br />+#endif /* _IPATH_REGISTERS_H */<br />diff --git a/drivers/infiniband/hw/ipath/ips_common.h b/drivers/infiniband/hw/ipath/ips_common.h<br />new file mode 100644<br />index 0000000..8a6a059<br />--- /dev/null<br />+++ b/drivers/infiniband/hw/ipath/ips_common.h<br />&#64;&#64; -0,0 +1,221 &#64;&#64;<br />+/*<br />+ * Copyright (c) 2003, 2004, 2005. PathScale, Inc. All rights reserved.<br />+ *<br />+ * This software is available to you under a choice of one of two<br />+ * licenses. You may choose to be licensed under the terms of the GNU<br />+ * General Public License (GPL) Version 2, available from the file<br />+ * COPYING in the main directory of this source tree, or the<br />+ * OpenIB.org BSD license below:<br />+ *<br />+ * Redistribution and use in source and binary forms, with or<br />+ * without modification, are permitted provided that the following<br />+ * conditions are met:<br />+ *<br />+ * - Redistributions of source code must retain the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer.<br />+ *<br />+ * - Redistributions in binary form must reproduce the above<br />+ * copyright notice, this list of conditions and the following<br />+ * disclaimer in the documentation and/or other materials<br />+ * provided with the distribution.<br />+ *<br />+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br />+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br />+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND<br />+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS<br />+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN<br />+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN<br />+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br />+ * SOFTWARE.<br />+ *<br />+ * Patent licenses, if any, provided herein do not apply to<br />+ * combinations of this program with other software, or any other<br />+ * product whatsoever.<br />+ *<br />+ * $Id: ips_common.h 4365 2005-12-10 00:04:16Z rjwalsh $<br />+ */<br />+<br />+#ifndef IPS_COMMON_H<br />+#define IPS_COMMON_H<br />+<br />+typedef struct _ipath_header_typ {<br />+ /*<br />+ * Version - 4 bits, Port - 4 bits, TID - 10 bits and Offset - 14 bits<br />+ * before ECO change ~28 Dec 03.<br />+ * After that, Vers 4, Port 3, TID 11, offset 14.<br />+ */<br />+ uint32_t ver_port_tid_offset;<br />+ uint16_t chksum;<br />+ uint16_t pkt_flags;<br />+} ipath_header_typ;<br />+<br />+typedef struct _ips_message_header_typ {<br />+ uint16_t lrh[4];<br />+ uint32_t bth[3];<br />+ ipath_header_typ iph;<br />+ uint8_t sub_opcode;<br />+ uint8_t flags;<br />+ uint16_t src_rank;<br />+ /* 24 bits. The upper 8 bit is available for other use */<br />+ union {<br />+ struct {<br />+ unsigned ack_seq_num : 24;<br />+ unsigned port : 4;<br />+ unsigned unused : 4;<br />+ };<br />+ uint32_t ack_seq_num_org;<br />+ };<br />+ uint8_t expected_tid_session_id;<br />+ uint8_t tinylen; /* to aid MPI */<br />+ uint16_t tag; /* to aid MPI */<br />+ union {<br />+ uint32_t mpi[4]; /* to aid MPI */<br />+ uint32_t data[4];<br />+ struct {<br />+ uint16_t mtu;<br />+ uint8_t major_ver;<br />+ uint8_t minor_ver;<br />+ uint32_t not_used; //free<br />+ uint32_t run_id;<br />+ uint32_t client_ver; <br />+ };<br />+ };<br />+} ips_message_header_typ;<br />+<br />+typedef struct _ether_header_typ {<br />+ uint16_t lrh[4];<br />+ uint32_t bth[3];<br />+ ipath_header_typ iph;<br />+ uint8_t sub_opcode;<br />+ uint8_t cmd;<br />+ uint16_t lid;<br />+ uint16_t mac[3];<br />+ uint8_t frag_num;<br />+ uint8_t seq_num;<br />+ uint32_t len;<br />+ /* MUST be of word size do to PIO write requirements */<br />+ uint32_t csum;<br />+ uint16_t csum_offset;<br />+ uint16_t flags;<br />+ uint16_t first_2_bytes;<br />+ uint8_t unused[2]; /* currently unused */<br />+} ether_header_typ;<br />+<br />+/*<br />+ * The PIO buffer used for sending infinipath messages must only be written<br />+ * in 32-bit words, all the data must be written, and no writes can occur<br />+ * after the last word is written (which transfers "ownership" of the buffer<br />+ * to the chip and triggers the message to be sent).<br />+ * Since the Linux sk_buff structure can be recursive, non-aligned, and<br />+ * any number of bytes in each segment, we use the following structure<br />+ * to keep information about the overall state of the copy operation.<br />+ * This is used to save the information needed to store the checksum<br />+ * in the right place before sending the last word to the hardware and<br />+ * to buffer the last 0-3 bytes of non-word sized segments.<br />+ */<br />+struct copy_data_s {<br />+ ether_header_typ *hdr;<br />+ uint32_t *csum_pio; /* address of the PIO buffer to write csum to */<br />+ uint32_t *to; /* address of the PIO buffer to write data to */<br />+ uint32_t device; /* which device to allocate PIO bufs from */<br />+ int error; /* set if there is an error. */<br />+ int extra; /* amount of data saved in u.buf below */<br />+ unsigned int len; /* total length to send in bytes */<br />+ unsigned int flen; /* frament length in words */<br />+ unsigned int csum; /* partial IP checksum */<br />+ unsigned int pos; /* position for partial checksum */<br />+ unsigned int offset; /* offset to where data currently starts */<br />+ int checksum_calc; /* set to 'true' when the checksum has been calculated */<br />+ struct sk_buff *skb;<br />+ union {<br />+ uint32_t w;<br />+ uint8_t buf[4];<br />+ } u;<br />+};<br />+<br />+typedef struct copy_data_s copy_data_ctrl_typ;<br />+<br />+/* IB - LRH header consts */<br />+#define IPS_LRH_GRH 0x0003 /* 1. word of IB LRH - next header: GRH */<br />+#define IPS_LRH_BTH 0x0002 /* 1. word of IB LRH - next header: BTH */<br />+<br />+#define IPS_OFFSET 0<br />+<br />+/*<br />+ * defines the cut-off point between the header queue and eager/expected<br />+ * TID queue<br />+ */<br />+#define NUM_OF_EKSTRA_WORDS_IN_HEADER_QUEUE ((sizeof(ips_message_header_typ) - offsetof(ips_message_header_typ, iph)) &gt;&gt; 2)<br />+<br />+/* OpCodes */<br />+#define OPCODE_IPS 0xC0<br />+#define OPCODE_ITH4X 0xC1<br />+<br />+/* OpCode 30 is use by stand-alone test programs */<br />+#define OPCODE_RAW_DATA 0xDE<br />+/* last OpCode (31) is reserved for test */<br />+#define OPCODE_TEST 0xDF<br />+<br />+/* sub OpCodes - ips */<br />+#define OPCODE_SEQ_DATA 0x01<br />+#define OPCODE_SEQ_CTRL 0x02<br />+<br />+#define OPCODE_ACK 0x10<br />+#define OPCODE_NAK 0x11<br />+<br />+#define OPCODE_ERR_CHK 0x20<br />+#define OPCODE_ERR_CHK_PLS 0x21<br />+<br />+#define OPCODE_STARTUP 0x30<br />+#define OPCODE_STARTUP_ACK 0x31<br />+#define OPCODE_STARTUP_NAK 0x32<br />+<br />+#define OPCODE_STARTUP_EXT 0x34<br />+#define OPCODE_STARTUP_ACK_EXT 0x35<br />+#define OPCODE_STARTUP_NAK_EXT 0x36<br />+<br />+#define OPCODE_TIDS_RELEASE 0x40<br />+#define OPCODE_TIDS_RELEASE_CONFIRM 0x41<br />+<br />+#define OPCODE_CLOSE 0x50<br />+#define OPCODE_CLOSE_ACK 0x51<br />+/*<br />+ * like OPCODE_CLOSE, but no complaint if other side has already closed. Used<br />+ * when doing abort(), MPI_Abort(), etc.<br />+ */<br />+#define OPCODE_ABORT 0x52<br />+<br />+/* sub OpCodes - ith4x */<br />+#define OPCODE_ENCAP 0x81<br />+#define OPCODE_LID_ARP 0x82<br />+<br />+/* Receive Header Queue: receive type (from infinipath) */<br />+#define RCVHQ_RCV_TYPE_EXPECTED 0<br />+#define RCVHQ_RCV_TYPE_EAGER 1<br />+#define RCVHQ_RCV_TYPE_NON_KD 2<br />+#define RCVHQ_RCV_TYPE_ERROR 3<br />+<br />+/* misc. */<br />+#define SIZE_OF_CRC 1<br />+<br />+#define EAGER_TID_ID INFINIPATH_I_TID_MASK<br />+<br />+#define IPS_DEFAULT_P_KEY 0xFFFF<br />+<br />+/* macros for processing rcvhdrq entries */<br />+#define ips_get_hdr_err_flags(StartOfBuffer) *(((uint32_t *)(StartOfBuffer))+1)<br />+#define ips_get_index(StartOfBuffer) (((*((uint32_t *)(StartOfBuffer))) &gt;&gt; \<br />+ INFINIPATH_RHF_EGRINDEX_SHIFT) &amp; INFINIPATH_RHF_EGRINDEX_MASK)<br />+#define ips_get_rcv_type(StartOfBuffer) ((*(((uint32_t *)(StartOfBuffer))) &gt;&gt; \<br />+ INFINIPATH_RHF_RCVTYPE_SHIFT) &amp; INFINIPATH_RHF_RCVTYPE_MASK)<br />+#define ips_get_length_in_bytes(StartOfBuffer) \<br />+ (uint32_t)(((*(((uint32_t *)(StartOfBuffer))) &gt;&gt; \<br />+ INFINIPATH_RHF_LENGTH_SHIFT) &amp; INFINIPATH_RHF_LENGTH_MASK) &lt;&lt; 2)<br />+#define ips_get_first_protocol_header(StartOfBuffer) (void *) \<br />+ ((uint32_t *)(StartOfBuffer) + 2)<br />+#define ips_get_ips_header(StartOfBuffer) ((ips_message_header_typ *) \<br />+ ((uint32_t *)(StartOfBuffer) + 2))<br />+#define ips_get_ipath_ver(ipath_header) (((ipath_header) &gt;&gt; INFINIPATH_I_VERS_SHIFT) \<br />+ &amp; INFINIPATH_I_VERS_MASK)<br />+#endif<br />-- <br />0.99.9n<br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo&#64;vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2005-12-17 00:53 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10