|
|
/home/brennan/n-sim/OrbisQuartus/server/xen/backend/sdev.hGo to the documentation of this file.00001 00012 /* 00013 * Copyright (c) 2002-2005, K A Fraser 00014 * 00015 * Copyright 2006. Los Alamos National Security, LLC. This material 00016 * was produced under U.S. Government contract DE-AC52-06NA25396 for 00017 * Los Alamos National Laboratory (LANL), which is operated by Los 00018 * Alamos National Security, LLC, for the Department of Energy. The 00019 * U.S. Government has rights to use, reproduce, and distribute this 00020 * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, 00021 * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL 00022 * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to 00023 * produce derivative works, such modified software should be clearly 00024 * marked, so as not to confuse it with the version available from LANL. 00025 * 00026 * Additionally, this program is free software; you can redistribute it 00027 * and/or modify it under the terms of the GNU General Public License as 00028 * published by the Free Software Foundation; either version 2 of the 00029 * License, or (at your option) any later version. Accordingly, this 00030 * program is distributed in the hope it will be useful, but WITHOUT ANY 00031 * WARRANTY; without even the implied warranty of MERCHANTABILITY or 00032 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00033 * for more details. 00034 ****************************** 00035 * 00036 * This program is free software; you can redistribute it and/or 00037 * modify it under the terms of the GNU General Public License version 2 00038 * as published by the Free Software Foundation; or, when distributed 00039 * separately from the Linux kernel or incorporated into other 00040 * software packages, subject to the following license: 00041 * 00042 * Permission is hereby granted, free of charge, to any person obtaining a copy 00043 * of this source file (the "Software"), to deal in the Software without 00044 * restriction, including without limitation the rights to use, copy, modify, 00045 * merge, publish, distribute, sublicense, and/or sell copies of the Software, 00046 * and to permit persons to whom the Software is furnished to do so, subject to 00047 * the following conditions: 00048 * 00049 * The above copyright notice and this permission notice shall be included in 00050 * all copies or substantial portions of the Software. 00051 * 00052 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00053 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00054 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00055 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00056 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00057 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 00058 * IN THE SOFTWARE. 00059 * 00060 * You should have received a copy of the GNU General Public License 00061 * along with this program; if not, write to the Free Software 00062 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00063 */ 00064 00065 00066 #ifndef __SENSOR__BACKEND__COMMON_H__ 00067 #define __SENSOR__BACKEND__COMMON_H__ 00068 00069 //#include <linux/autoconf.h> 00070 #include <linux/version.h> 00071 #include <linux/module.h> 00072 #include <linux/interrupt.h> 00073 #include <linux/slab.h> 00074 #include <linux/ip.h> 00075 #include <linux/in.h> 00076 #include <linux/netdevice.h> 00077 #include <linux/etherdevice.h> 00078 #include <asm/io.h> 00079 #include <asm/pgalloc.h> 00080 00081 #include <xen/evtchn.h> 00082 #include <xen/interface/io/netif.h> 00083 #include <xen/interface/grant_table.h> 00084 #include <xen/gnttab.h> 00085 #include <xen/driver_util.h> 00086 00087 00088 #define DPRINTK(_f, _a...) pr_debug("(file=%s, line=%d) " _f, \ 00089 __FILE__ , __LINE__ , ## _a ) 00090 00091 00092 typedef struct sdev_st { 00093 /* Unique identifier for this interface. */ 00094 domid_t domid; 00095 unsigned int handle; 00096 00097 u8 fe_dev_addr[6]; 00098 00099 /* Physical parameters of the comms window. */ 00100 grant_handle_t tx_shmem_handle; 00101 grant_ref_t tx_shmem_ref; 00102 grant_handle_t rx_shmem_handle; 00103 grant_ref_t rx_shmem_ref; 00104 unsigned int evtchn; 00105 unsigned int irq; 00106 00107 /* The shared rings and indexes. */ 00108 netif_tx_back_ring_t tx; 00109 netif_rx_back_ring_t rx; 00110 struct vm_struct *tx_comms_area; 00111 struct vm_struct *rx_comms_area; 00112 00113 /* Allow sdev_be_start_xmit() to peek ahead in the rx request ring. */ 00114 RING_IDX rx_req_cons_peek; 00115 00116 /* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */ 00117 unsigned long credit_bytes; 00118 unsigned long credit_usec; 00119 unsigned long remaining_credit; 00120 struct timer_list credit_timeout; 00121 00122 /* Miscellaneous private stuff. */ 00123 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status; 00124 int active; 00125 struct list_head list; /* scheduling list */ 00126 atomic_t refcnt; 00127 struct net_device *dev; 00128 struct net_device_stats stats; 00129 00130 struct work_struct free_work; 00131 } sdev_t; 00132 00133 #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE) 00134 #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE) 00135 00136 void sdev_creditlimit(sdev_t *sdev); 00137 void sdev_disconnect(sdev_t *sdev); 00138 00139 sdev_t *alloc_sdev(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]); 00140 void free_sdev(sdev_t *sdev); 00141 int sdev_map(sdev_t *sdev, unsigned long tx_ring_ref, 00142 unsigned long rx_ring_ref, unsigned int evtchn); 00143 00144 #define sdev_get(_b) (atomic_inc(&(_b)->refcnt)) 00145 #define sdev_put(_b) \ 00146 do { \ 00147 if ( atomic_dec_and_test(&(_b)->refcnt) ) \ 00148 free_sdev(_b); \ 00149 } while (0) 00150 00151 void sdev_xenbus_init(void); 00152 void sdev_xenbus_exit(void); 00153 00154 void sdev_schedule_work(sdev_t *sdev); 00155 void sdev_deschedule_work(sdev_t *sdev); 00156 00157 int sdev_be_start_xmit(struct sk_buff *skb, struct net_device *dev); 00158 struct net_device_stats *sdev_be_get_stats(struct net_device *dev); 00159 irqreturn_t sdev_be_int(int irq, void *dev_id, struct pt_regs *regs); 00160 00161 #endif /* __SENSOR__BACKEND__COMMON_H__ */ |