David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the Solos PCI ADSL2+ card, designed to support Linux by |
| 3 | * Traverse Technologies -- http://www.traverse.com.au/ |
| 4 | * Xrio Limited -- http://www.xrio.com/ |
| 5 | * |
| 6 | * |
| 7 | * Copyright © 2008 Traverse Technologies |
| 8 | * Copyright © 2008 Intel Corporation |
| 9 | * |
| 10 | * Authors: Nathan Williams <nathan@traverse.com.au> |
| 11 | * David Woodhouse <dwmw2@infradead.org> |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 12 | * Treker Chen <treker@xrio.com> |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * version 2, as published by the Free Software Foundation. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | */ |
| 23 | |
| 24 | #define DEBUG |
| 25 | #define VERBOSE_DEBUG |
| 26 | |
| 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/module.h> |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/errno.h> |
| 31 | #include <linux/ioport.h> |
| 32 | #include <linux/types.h> |
| 33 | #include <linux/pci.h> |
| 34 | #include <linux/atm.h> |
| 35 | #include <linux/atmdev.h> |
| 36 | #include <linux/skbuff.h> |
| 37 | #include <linux/sysfs.h> |
| 38 | #include <linux/device.h> |
| 39 | #include <linux/kobject.h> |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 40 | #include <linux/firmware.h> |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 41 | #include <linux/ctype.h> |
| 42 | #include <linux/swab.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 43 | #include <linux/slab.h> |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 44 | |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 45 | #define VERSION "0.07" |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 46 | #define PTAG "solos-pci" |
| 47 | |
| 48 | #define CONFIG_RAM_SIZE 128 |
| 49 | #define FLAGS_ADDR 0x7C |
| 50 | #define IRQ_EN_ADDR 0x78 |
| 51 | #define FPGA_VER 0x74 |
| 52 | #define IRQ_CLEAR 0x70 |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 53 | #define WRITE_FLASH 0x6C |
| 54 | #define PORTS 0x68 |
| 55 | #define FLASH_BLOCK 0x64 |
| 56 | #define FLASH_BUSY 0x60 |
| 57 | #define FPGA_MODE 0x5C |
| 58 | #define FLASH_MODE 0x58 |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 59 | #define TX_DMA_ADDR(port) (0x40 + (4 * (port))) |
| 60 | #define RX_DMA_ADDR(port) (0x30 + (4 * (port))) |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 61 | |
| 62 | #define DATA_RAM_SIZE 32768 |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 63 | #define BUF_SIZE 2048 |
| 64 | #define OLD_BUF_SIZE 4096 /* For FPGA versions <= 2*/ |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 65 | #define FPGA_PAGE 528 /* FPGA flash page size*/ |
| 66 | #define SOLOS_PAGE 512 /* Solos flash page size*/ |
| 67 | #define FPGA_BLOCK (FPGA_PAGE * 8) /* FPGA flash block size*/ |
| 68 | #define SOLOS_BLOCK (SOLOS_PAGE * 8) /* Solos flash block size*/ |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 69 | |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 70 | #define RX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2) |
| 71 | #define TX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2 + (card->buffer_size)) |
| 72 | #define FLASH_BUF ((card->buffers) + 4*(card->buffer_size)*2) |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 73 | |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 74 | #define RX_DMA_SIZE 2048 |
| 75 | |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 76 | #define FPGA_VERSION(a,b) (((a) << 8) + (b)) |
| 77 | #define LEGACY_BUFFERS 2 |
| 78 | #define DMA_SUPPORTED 4 |
| 79 | |
David Woodhouse | cc3657e | 2009-01-30 14:23:22 +1100 | [diff] [blame] | 80 | static int reset = 0; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 81 | static int atmdebug = 0; |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 82 | static int firmware_upgrade = 0; |
| 83 | static int fpga_upgrade = 0; |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 84 | static int db_firmware_upgrade = 0; |
| 85 | static int db_fpga_upgrade = 0; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 86 | |
| 87 | struct pkt_hdr { |
| 88 | __le16 size; |
| 89 | __le16 vpi; |
| 90 | __le16 vci; |
| 91 | __le16 type; |
| 92 | }; |
| 93 | |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 94 | struct solos_skb_cb { |
| 95 | struct atm_vcc *vcc; |
| 96 | uint32_t dma_addr; |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | #define SKB_CB(skb) ((struct solos_skb_cb *)skb->cb) |
| 101 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 102 | #define PKT_DATA 0 |
| 103 | #define PKT_COMMAND 1 |
| 104 | #define PKT_POPEN 3 |
| 105 | #define PKT_PCLOSE 4 |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 106 | #define PKT_STATUS 5 |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 107 | |
| 108 | struct solos_card { |
| 109 | void __iomem *config_regs; |
| 110 | void __iomem *buffers; |
| 111 | int nr_ports; |
David Woodhouse | f69e417 | 2009-01-29 11:10:58 +1100 | [diff] [blame] | 112 | int tx_mask; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 113 | struct pci_dev *dev; |
| 114 | struct atm_dev *atmdev[4]; |
| 115 | struct tasklet_struct tlet; |
| 116 | spinlock_t tx_lock; |
| 117 | spinlock_t tx_queue_lock; |
| 118 | spinlock_t cli_queue_lock; |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 119 | spinlock_t param_queue_lock; |
| 120 | struct list_head param_queue; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 121 | struct sk_buff_head tx_queue[4]; |
| 122 | struct sk_buff_head cli_queue[4]; |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 123 | struct sk_buff *tx_skb[4]; |
| 124 | struct sk_buff *rx_skb[4]; |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 125 | wait_queue_head_t param_wq; |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 126 | wait_queue_head_t fw_wq; |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 127 | int using_dma; |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 128 | int fpga_version; |
| 129 | int buffer_size; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 132 | |
| 133 | struct solos_param { |
| 134 | struct list_head list; |
| 135 | pid_t pid; |
| 136 | int port; |
| 137 | struct sk_buff *response; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | #define SOLOS_CHAN(atmdev) ((int)(unsigned long)(atmdev)->phy_data) |
| 141 | |
| 142 | MODULE_AUTHOR("Traverse Technologies <support@traverse.com.au>"); |
| 143 | MODULE_DESCRIPTION("Solos PCI driver"); |
| 144 | MODULE_VERSION(VERSION); |
| 145 | MODULE_LICENSE("GPL"); |
Ben Hutchings | 9fca79d | 2009-11-07 11:40:32 +0000 | [diff] [blame] | 146 | MODULE_FIRMWARE("solos-FPGA.bin"); |
| 147 | MODULE_FIRMWARE("solos-Firmware.bin"); |
| 148 | MODULE_FIRMWARE("solos-db-FPGA.bin"); |
David Woodhouse | cc3657e | 2009-01-30 14:23:22 +1100 | [diff] [blame] | 149 | MODULE_PARM_DESC(reset, "Reset Solos chips on startup"); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 150 | MODULE_PARM_DESC(atmdebug, "Print ATM data"); |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 151 | MODULE_PARM_DESC(firmware_upgrade, "Initiate Solos firmware upgrade"); |
| 152 | MODULE_PARM_DESC(fpga_upgrade, "Initiate FPGA upgrade"); |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 153 | MODULE_PARM_DESC(db_firmware_upgrade, "Initiate daughter board Solos firmware upgrade"); |
| 154 | MODULE_PARM_DESC(db_fpga_upgrade, "Initiate daughter board FPGA upgrade"); |
David Woodhouse | cc3657e | 2009-01-30 14:23:22 +1100 | [diff] [blame] | 155 | module_param(reset, int, 0444); |
Simon Farnsworth | 4306cad | 2009-01-19 21:19:29 +0000 | [diff] [blame] | 156 | module_param(atmdebug, int, 0644); |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 157 | module_param(firmware_upgrade, int, 0444); |
| 158 | module_param(fpga_upgrade, int, 0444); |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 159 | module_param(db_firmware_upgrade, int, 0444); |
| 160 | module_param(db_fpga_upgrade, int, 0444); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 161 | |
| 162 | static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb, |
| 163 | struct atm_vcc *vcc); |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 164 | static uint32_t fpga_tx(struct solos_card *); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 165 | static irqreturn_t solos_irq(int irq, void *dev_id); |
| 166 | static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci); |
| 167 | static int list_vccs(int vci); |
Dan Williams | d9ca676 | 2010-12-08 19:40:47 +0000 | [diff] [blame] | 168 | static int atm_init(struct solos_card *, struct device *); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 169 | static void atm_remove(struct solos_card *); |
| 170 | static int send_command(struct solos_card *card, int dev, const char *buf, size_t size); |
| 171 | static void solos_bh(unsigned long); |
| 172 | static int print_buffer(struct sk_buff *buf); |
| 173 | |
| 174 | static inline void solos_pop(struct atm_vcc *vcc, struct sk_buff *skb) |
| 175 | { |
| 176 | if (vcc->pop) |
| 177 | vcc->pop(vcc, skb); |
| 178 | else |
| 179 | dev_kfree_skb_any(skb); |
| 180 | } |
| 181 | |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 182 | static ssize_t solos_param_show(struct device *dev, struct device_attribute *attr, |
| 183 | char *buf) |
| 184 | { |
| 185 | struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev); |
| 186 | struct solos_card *card = atmdev->dev_data; |
| 187 | struct solos_param prm; |
| 188 | struct sk_buff *skb; |
| 189 | struct pkt_hdr *header; |
| 190 | int buflen; |
| 191 | |
| 192 | buflen = strlen(attr->attr.name) + 10; |
| 193 | |
David Woodhouse | 3456b22 | 2009-01-28 10:39:23 +1100 | [diff] [blame] | 194 | skb = alloc_skb(sizeof(*header) + buflen, GFP_KERNEL); |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 195 | if (!skb) { |
| 196 | dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_show()\n"); |
| 197 | return -ENOMEM; |
| 198 | } |
| 199 | |
| 200 | header = (void *)skb_put(skb, sizeof(*header)); |
| 201 | |
| 202 | buflen = snprintf((void *)&header[1], buflen - 1, |
| 203 | "L%05d\n%s\n", current->pid, attr->attr.name); |
| 204 | skb_put(skb, buflen); |
| 205 | |
| 206 | header->size = cpu_to_le16(buflen); |
| 207 | header->vpi = cpu_to_le16(0); |
| 208 | header->vci = cpu_to_le16(0); |
| 209 | header->type = cpu_to_le16(PKT_COMMAND); |
| 210 | |
| 211 | prm.pid = current->pid; |
| 212 | prm.response = NULL; |
| 213 | prm.port = SOLOS_CHAN(atmdev); |
| 214 | |
| 215 | spin_lock_irq(&card->param_queue_lock); |
| 216 | list_add(&prm.list, &card->param_queue); |
| 217 | spin_unlock_irq(&card->param_queue_lock); |
| 218 | |
| 219 | fpga_queue(card, prm.port, skb, NULL); |
| 220 | |
| 221 | wait_event_timeout(card->param_wq, prm.response, 5 * HZ); |
| 222 | |
| 223 | spin_lock_irq(&card->param_queue_lock); |
| 224 | list_del(&prm.list); |
| 225 | spin_unlock_irq(&card->param_queue_lock); |
| 226 | |
| 227 | if (!prm.response) |
| 228 | return -EIO; |
| 229 | |
| 230 | buflen = prm.response->len; |
| 231 | memcpy(buf, prm.response->data, buflen); |
| 232 | kfree_skb(prm.response); |
| 233 | |
| 234 | return buflen; |
| 235 | } |
| 236 | |
| 237 | static ssize_t solos_param_store(struct device *dev, struct device_attribute *attr, |
| 238 | const char *buf, size_t count) |
| 239 | { |
| 240 | struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev); |
| 241 | struct solos_card *card = atmdev->dev_data; |
| 242 | struct solos_param prm; |
| 243 | struct sk_buff *skb; |
| 244 | struct pkt_hdr *header; |
| 245 | int buflen; |
| 246 | ssize_t ret; |
| 247 | |
| 248 | buflen = strlen(attr->attr.name) + 11 + count; |
| 249 | |
David Woodhouse | 3456b22 | 2009-01-28 10:39:23 +1100 | [diff] [blame] | 250 | skb = alloc_skb(sizeof(*header) + buflen, GFP_KERNEL); |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 251 | if (!skb) { |
| 252 | dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_store()\n"); |
| 253 | return -ENOMEM; |
| 254 | } |
| 255 | |
| 256 | header = (void *)skb_put(skb, sizeof(*header)); |
| 257 | |
| 258 | buflen = snprintf((void *)&header[1], buflen - 1, |
| 259 | "L%05d\n%s\n%s\n", current->pid, attr->attr.name, buf); |
| 260 | |
| 261 | skb_put(skb, buflen); |
| 262 | header->size = cpu_to_le16(buflen); |
| 263 | header->vpi = cpu_to_le16(0); |
| 264 | header->vci = cpu_to_le16(0); |
| 265 | header->type = cpu_to_le16(PKT_COMMAND); |
| 266 | |
| 267 | prm.pid = current->pid; |
| 268 | prm.response = NULL; |
| 269 | prm.port = SOLOS_CHAN(atmdev); |
| 270 | |
| 271 | spin_lock_irq(&card->param_queue_lock); |
| 272 | list_add(&prm.list, &card->param_queue); |
| 273 | spin_unlock_irq(&card->param_queue_lock); |
| 274 | |
| 275 | fpga_queue(card, prm.port, skb, NULL); |
| 276 | |
| 277 | wait_event_timeout(card->param_wq, prm.response, 5 * HZ); |
| 278 | |
| 279 | spin_lock_irq(&card->param_queue_lock); |
| 280 | list_del(&prm.list); |
| 281 | spin_unlock_irq(&card->param_queue_lock); |
| 282 | |
| 283 | skb = prm.response; |
| 284 | |
| 285 | if (!skb) |
| 286 | return -EIO; |
| 287 | |
| 288 | buflen = skb->len; |
| 289 | |
| 290 | /* Sometimes it has a newline, sometimes it doesn't. */ |
| 291 | if (skb->data[buflen - 1] == '\n') |
| 292 | buflen--; |
| 293 | |
| 294 | if (buflen == 2 && !strncmp(skb->data, "OK", 2)) |
| 295 | ret = count; |
| 296 | else if (buflen == 5 && !strncmp(skb->data, "ERROR", 5)) |
| 297 | ret = -EIO; |
| 298 | else { |
| 299 | /* We know we have enough space allocated for this; we allocated |
| 300 | it ourselves */ |
| 301 | skb->data[buflen] = 0; |
| 302 | |
| 303 | dev_warn(&card->dev->dev, "Unexpected parameter response: '%s'\n", |
| 304 | skb->data); |
| 305 | ret = -EIO; |
| 306 | } |
| 307 | kfree_skb(skb); |
| 308 | |
| 309 | return ret; |
| 310 | } |
| 311 | |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 312 | static char *next_string(struct sk_buff *skb) |
| 313 | { |
| 314 | int i = 0; |
| 315 | char *this = skb->data; |
David Woodhouse | c6428e5 | 2009-01-29 12:17:09 +1100 | [diff] [blame] | 316 | |
| 317 | for (i = 0; i < skb->len; i++) { |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 318 | if (this[i] == '\n') { |
| 319 | this[i] = 0; |
David Woodhouse | c6428e5 | 2009-01-29 12:17:09 +1100 | [diff] [blame] | 320 | skb_pull(skb, i + 1); |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 321 | return this; |
| 322 | } |
David Woodhouse | c6428e5 | 2009-01-29 12:17:09 +1100 | [diff] [blame] | 323 | if (!isprint(this[i])) |
| 324 | return NULL; |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 325 | } |
| 326 | return NULL; |
| 327 | } |
| 328 | |
| 329 | /* |
| 330 | * Status packet has fields separated by \n, starting with a version number |
| 331 | * for the information therein. Fields are.... |
| 332 | * |
| 333 | * packet version |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 334 | * RxBitRate (version >= 1) |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 335 | * TxBitRate (version >= 1) |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 336 | * State (version >= 1) |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 337 | * LocalSNRMargin (version >= 1) |
| 338 | * LocalLineAttn (version >= 1) |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 339 | */ |
| 340 | static int process_status(struct solos_card *card, int port, struct sk_buff *skb) |
| 341 | { |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 342 | char *str, *end, *state_str, *snr, *attn; |
| 343 | int ver, rate_up, rate_down; |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 344 | |
| 345 | if (!card->atmdev[port]) |
| 346 | return -ENODEV; |
| 347 | |
| 348 | str = next_string(skb); |
| 349 | if (!str) |
| 350 | return -EIO; |
| 351 | |
| 352 | ver = simple_strtol(str, NULL, 10); |
| 353 | if (ver < 1) { |
| 354 | dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n", |
| 355 | ver); |
| 356 | return -EIO; |
| 357 | } |
| 358 | |
| 359 | str = next_string(skb); |
David Woodhouse | c6428e5 | 2009-01-29 12:17:09 +1100 | [diff] [blame] | 360 | if (!str) |
| 361 | return -EIO; |
David Woodhouse | 95852f4 | 2009-01-30 14:23:52 +1100 | [diff] [blame] | 362 | if (!strcmp(str, "ERROR")) { |
| 363 | dev_dbg(&card->dev->dev, "Status packet indicated Solos error on port %d (starting up?)\n", |
| 364 | port); |
| 365 | return 0; |
| 366 | } |
| 367 | |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 368 | rate_down = simple_strtol(str, &end, 10); |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 369 | if (*end) |
| 370 | return -EIO; |
| 371 | |
| 372 | str = next_string(skb); |
David Woodhouse | c6428e5 | 2009-01-29 12:17:09 +1100 | [diff] [blame] | 373 | if (!str) |
| 374 | return -EIO; |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 375 | rate_up = simple_strtol(str, &end, 10); |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 376 | if (*end) |
| 377 | return -EIO; |
| 378 | |
David Woodhouse | af78065 | 2009-01-28 10:22:57 +1100 | [diff] [blame] | 379 | state_str = next_string(skb); |
David Woodhouse | c6428e5 | 2009-01-29 12:17:09 +1100 | [diff] [blame] | 380 | if (!state_str) |
| 381 | return -EIO; |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 382 | |
| 383 | /* Anything but 'Showtime' is down */ |
| 384 | if (strcmp(state_str, "Showtime")) { |
Karl Hiramoto | 49d4910 | 2010-07-08 20:55:34 +0000 | [diff] [blame] | 385 | atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_LOST); |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 386 | dev_info(&card->dev->dev, "Port %d: %s\n", port, state_str); |
| 387 | return 0; |
David Woodhouse | 1e615df | 2009-01-27 21:47:47 +1100 | [diff] [blame] | 388 | } |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 389 | |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 390 | snr = next_string(skb); |
Julia Lawall | 6cf5767 | 2009-07-27 11:38:52 -0700 | [diff] [blame] | 391 | if (!snr) |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 392 | return -EIO; |
| 393 | attn = next_string(skb); |
| 394 | if (!attn) |
| 395 | return -EIO; |
David Woodhouse | af78065 | 2009-01-28 10:22:57 +1100 | [diff] [blame] | 396 | |
David Woodhouse | f87b2ed | 2009-01-30 14:31:36 +1100 | [diff] [blame] | 397 | dev_info(&card->dev->dev, "Port %d: %s @%d/%d kb/s%s%s%s%s\n", |
| 398 | port, state_str, rate_down/1000, rate_up/1000, |
| 399 | snr[0]?", SNR ":"", snr, attn[0]?", Attn ":"", attn); |
| 400 | |
David Woodhouse | c6428e5 | 2009-01-29 12:17:09 +1100 | [diff] [blame] | 401 | card->atmdev[port]->link_rate = rate_down / 424; |
Karl Hiramoto | 49d4910 | 2010-07-08 20:55:34 +0000 | [diff] [blame] | 402 | atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_FOUND); |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 403 | |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 404 | return 0; |
| 405 | } |
| 406 | |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 407 | static int process_command(struct solos_card *card, int port, struct sk_buff *skb) |
| 408 | { |
| 409 | struct solos_param *prm; |
| 410 | unsigned long flags; |
| 411 | int cmdpid; |
| 412 | int found = 0; |
| 413 | |
| 414 | if (skb->len < 7) |
| 415 | return 0; |
| 416 | |
| 417 | if (skb->data[0] != 'L' || !isdigit(skb->data[1]) || |
| 418 | !isdigit(skb->data[2]) || !isdigit(skb->data[3]) || |
| 419 | !isdigit(skb->data[4]) || !isdigit(skb->data[5]) || |
| 420 | skb->data[6] != '\n') |
| 421 | return 0; |
| 422 | |
| 423 | cmdpid = simple_strtol(&skb->data[1], NULL, 10); |
| 424 | |
| 425 | spin_lock_irqsave(&card->param_queue_lock, flags); |
| 426 | list_for_each_entry(prm, &card->param_queue, list) { |
| 427 | if (prm->port == port && prm->pid == cmdpid) { |
| 428 | prm->response = skb; |
| 429 | skb_pull(skb, 7); |
| 430 | wake_up(&card->param_wq); |
| 431 | found = 1; |
| 432 | break; |
| 433 | } |
| 434 | } |
| 435 | spin_unlock_irqrestore(&card->param_queue_lock, flags); |
| 436 | return found; |
| 437 | } |
| 438 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 439 | static ssize_t console_show(struct device *dev, struct device_attribute *attr, |
| 440 | char *buf) |
| 441 | { |
| 442 | struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev); |
| 443 | struct solos_card *card = atmdev->dev_data; |
| 444 | struct sk_buff *skb; |
Jiri Slaby | f1ee89d | 2010-10-10 21:50:44 +0000 | [diff] [blame] | 445 | unsigned int len; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 446 | |
| 447 | spin_lock(&card->cli_queue_lock); |
| 448 | skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]); |
| 449 | spin_unlock(&card->cli_queue_lock); |
| 450 | if(skb == NULL) |
| 451 | return sprintf(buf, "No data.\n"); |
| 452 | |
Jiri Slaby | f1ee89d | 2010-10-10 21:50:44 +0000 | [diff] [blame] | 453 | len = skb->len; |
| 454 | memcpy(buf, skb->data, len); |
| 455 | dev_dbg(&card->dev->dev, "len: %d\n", len); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 456 | |
| 457 | kfree_skb(skb); |
Jiri Slaby | f1ee89d | 2010-10-10 21:50:44 +0000 | [diff] [blame] | 458 | return len; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | static int send_command(struct solos_card *card, int dev, const char *buf, size_t size) |
| 462 | { |
| 463 | struct sk_buff *skb; |
| 464 | struct pkt_hdr *header; |
| 465 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 466 | if (size > (BUF_SIZE - sizeof(*header))) { |
| 467 | dev_dbg(&card->dev->dev, "Command is too big. Dropping request\n"); |
| 468 | return 0; |
| 469 | } |
| 470 | skb = alloc_skb(size + sizeof(*header), GFP_ATOMIC); |
| 471 | if (!skb) { |
| 472 | dev_warn(&card->dev->dev, "Failed to allocate sk_buff in send_command()\n"); |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | header = (void *)skb_put(skb, sizeof(*header)); |
| 477 | |
| 478 | header->size = cpu_to_le16(size); |
| 479 | header->vpi = cpu_to_le16(0); |
| 480 | header->vci = cpu_to_le16(0); |
| 481 | header->type = cpu_to_le16(PKT_COMMAND); |
| 482 | |
| 483 | memcpy(skb_put(skb, size), buf, size); |
| 484 | |
| 485 | fpga_queue(card, dev, skb, NULL); |
| 486 | |
| 487 | return 0; |
| 488 | } |
| 489 | |
| 490 | static ssize_t console_store(struct device *dev, struct device_attribute *attr, |
| 491 | const char *buf, size_t count) |
| 492 | { |
| 493 | struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev); |
| 494 | struct solos_card *card = atmdev->dev_data; |
| 495 | int err; |
| 496 | |
| 497 | err = send_command(card, SOLOS_CHAN(atmdev), buf, count); |
| 498 | |
| 499 | return err?:count; |
| 500 | } |
| 501 | |
| 502 | static DEVICE_ATTR(console, 0644, console_show, console_store); |
| 503 | |
David Woodhouse | d057f0a | 2009-01-27 16:52:07 +1100 | [diff] [blame] | 504 | |
| 505 | #define SOLOS_ATTR_RO(x) static DEVICE_ATTR(x, 0444, solos_param_show, NULL); |
| 506 | #define SOLOS_ATTR_RW(x) static DEVICE_ATTR(x, 0644, solos_param_show, solos_param_store); |
| 507 | |
| 508 | #include "solos-attrlist.c" |
| 509 | |
| 510 | #undef SOLOS_ATTR_RO |
| 511 | #undef SOLOS_ATTR_RW |
| 512 | |
| 513 | #define SOLOS_ATTR_RO(x) &dev_attr_##x.attr, |
| 514 | #define SOLOS_ATTR_RW(x) &dev_attr_##x.attr, |
| 515 | |
| 516 | static struct attribute *solos_attrs[] = { |
| 517 | #include "solos-attrlist.c" |
| 518 | NULL |
| 519 | }; |
| 520 | |
| 521 | static struct attribute_group solos_attr_group = { |
| 522 | .attrs = solos_attrs, |
| 523 | .name = "parameters", |
| 524 | }; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 525 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 526 | static int flash_upgrade(struct solos_card *card, int chip) |
| 527 | { |
| 528 | const struct firmware *fw; |
| 529 | const char *fw_name; |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 530 | uint32_t data32 = 0; |
| 531 | int blocksize = 0; |
| 532 | int numblocks = 0; |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 533 | int offset; |
| 534 | |
Andrew Morton | 7adcdb4 | 2009-11-17 12:46:44 +0000 | [diff] [blame] | 535 | switch (chip) { |
| 536 | case 0: |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 537 | fw_name = "solos-FPGA.bin"; |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 538 | blocksize = FPGA_BLOCK; |
Andrew Morton | 7adcdb4 | 2009-11-17 12:46:44 +0000 | [diff] [blame] | 539 | break; |
| 540 | case 1: |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 541 | fw_name = "solos-Firmware.bin"; |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 542 | blocksize = SOLOS_BLOCK; |
Andrew Morton | 7adcdb4 | 2009-11-17 12:46:44 +0000 | [diff] [blame] | 543 | break; |
| 544 | case 2: |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 545 | if (card->fpga_version > LEGACY_BUFFERS){ |
| 546 | fw_name = "solos-db-FPGA.bin"; |
| 547 | blocksize = FPGA_BLOCK; |
| 548 | } else { |
Andrew Morton | 7adcdb4 | 2009-11-17 12:46:44 +0000 | [diff] [blame] | 549 | dev_info(&card->dev->dev, "FPGA version doesn't support" |
| 550 | " daughter board upgrades\n"); |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 551 | return -EPERM; |
| 552 | } |
Andrew Morton | 7adcdb4 | 2009-11-17 12:46:44 +0000 | [diff] [blame] | 553 | break; |
| 554 | case 3: |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 555 | if (card->fpga_version > LEGACY_BUFFERS){ |
| 556 | fw_name = "solos-Firmware.bin"; |
| 557 | blocksize = SOLOS_BLOCK; |
| 558 | } else { |
Andrew Morton | 7adcdb4 | 2009-11-17 12:46:44 +0000 | [diff] [blame] | 559 | dev_info(&card->dev->dev, "FPGA version doesn't support" |
| 560 | " daughter board upgrades\n"); |
| 561 | return -EPERM; |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 562 | } |
Andrew Morton | 7adcdb4 | 2009-11-17 12:46:44 +0000 | [diff] [blame] | 563 | break; |
| 564 | default: |
| 565 | return -ENODEV; |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 566 | } |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 567 | |
| 568 | if (request_firmware(&fw, fw_name, &card->dev->dev)) |
| 569 | return -ENOENT; |
| 570 | |
| 571 | dev_info(&card->dev->dev, "Flash upgrade starting\n"); |
| 572 | |
| 573 | numblocks = fw->size / blocksize; |
| 574 | dev_info(&card->dev->dev, "Firmware size: %zd\n", fw->size); |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 575 | dev_info(&card->dev->dev, "Number of blocks: %d\n", numblocks); |
| 576 | |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 577 | dev_info(&card->dev->dev, "Changing FPGA to Update mode\n"); |
| 578 | iowrite32(1, card->config_regs + FPGA_MODE); |
| 579 | data32 = ioread32(card->config_regs + FPGA_MODE); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 580 | |
| 581 | /* Set mode to Chip Erase */ |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 582 | if(chip == 0 || chip == 2) |
| 583 | dev_info(&card->dev->dev, "Set FPGA Flash mode to FPGA Chip Erase\n"); |
| 584 | if(chip == 1 || chip == 3) |
| 585 | dev_info(&card->dev->dev, "Set FPGA Flash mode to Solos Chip Erase\n"); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 586 | iowrite32((chip * 2), card->config_regs + FLASH_MODE); |
| 587 | |
| 588 | |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 589 | iowrite32(1, card->config_regs + WRITE_FLASH); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 590 | wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY)); |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 591 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 592 | for (offset = 0; offset < fw->size; offset += blocksize) { |
| 593 | int i; |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 594 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 595 | /* Clear write flag */ |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 596 | iowrite32(0, card->config_regs + WRITE_FLASH); |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 597 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 598 | /* Set mode to Block Write */ |
| 599 | /* dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n"); */ |
| 600 | iowrite32(((chip * 2) + 1), card->config_regs + FLASH_MODE); |
| 601 | |
| 602 | /* Copy block to buffer, swapping each 16 bits */ |
| 603 | for(i = 0; i < blocksize; i += 4) { |
| 604 | uint32_t word = swahb32p((uint32_t *)(fw->data + offset + i)); |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 605 | if(card->fpga_version > LEGACY_BUFFERS) |
| 606 | iowrite32(word, FLASH_BUF + i); |
| 607 | else |
| 608 | iowrite32(word, RX_BUF(card, 3) + i); |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 609 | } |
| 610 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 611 | /* Specify block number and then trigger flash write */ |
| 612 | iowrite32(offset / blocksize, card->config_regs + FLASH_BLOCK); |
| 613 | iowrite32(1, card->config_regs + WRITE_FLASH); |
| 614 | wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY)); |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 615 | } |
| 616 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 617 | release_firmware(fw); |
| 618 | iowrite32(0, card->config_regs + WRITE_FLASH); |
| 619 | iowrite32(0, card->config_regs + FPGA_MODE); |
| 620 | iowrite32(0, card->config_regs + FLASH_MODE); |
| 621 | dev_info(&card->dev->dev, "Returning FPGA to Data mode\n"); |
| 622 | return 0; |
Simon Farnsworth | 7c4015b | 2009-01-21 20:45:49 +0000 | [diff] [blame] | 623 | } |
| 624 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 625 | static irqreturn_t solos_irq(int irq, void *dev_id) |
| 626 | { |
| 627 | struct solos_card *card = dev_id; |
| 628 | int handled = 1; |
| 629 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 630 | iowrite32(0, card->config_regs + IRQ_CLEAR); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 631 | |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 632 | /* If we're up and running, just kick the tasklet to process TX/RX */ |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 633 | if (card->atmdev[0]) |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 634 | tasklet_schedule(&card->tlet); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 635 | else |
| 636 | wake_up(&card->fw_wq); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 637 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 638 | return IRQ_RETVAL(handled); |
| 639 | } |
| 640 | |
| 641 | void solos_bh(unsigned long card_arg) |
| 642 | { |
| 643 | struct solos_card *card = (void *)card_arg; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 644 | uint32_t card_flags; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 645 | uint32_t rx_done = 0; |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 646 | int port; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 647 | |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 648 | /* |
| 649 | * Since fpga_tx() is going to need to read the flags under its lock, |
| 650 | * it can return them to us so that we don't have to hit PCI MMIO |
| 651 | * again for the same information |
| 652 | */ |
| 653 | card_flags = fpga_tx(card); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 654 | |
| 655 | for (port = 0; port < card->nr_ports; port++) { |
| 656 | if (card_flags & (0x10 << port)) { |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 657 | struct pkt_hdr _hdr, *header; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 658 | struct sk_buff *skb; |
| 659 | struct atm_vcc *vcc; |
| 660 | int size; |
| 661 | |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 662 | if (card->using_dma) { |
| 663 | skb = card->rx_skb[port]; |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 664 | card->rx_skb[port] = NULL; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 665 | |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 666 | pci_unmap_single(card->dev, SKB_CB(skb)->dma_addr, |
| 667 | RX_DMA_SIZE, PCI_DMA_FROMDEVICE); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 668 | |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 669 | header = (void *)skb->data; |
| 670 | size = le16_to_cpu(header->size); |
| 671 | skb_put(skb, size + sizeof(*header)); |
| 672 | skb_pull(skb, sizeof(*header)); |
| 673 | } else { |
| 674 | header = &_hdr; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 675 | |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 676 | rx_done |= 0x10 << port; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 677 | |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 678 | memcpy_fromio(header, RX_BUF(card, port), sizeof(*header)); |
| 679 | |
| 680 | size = le16_to_cpu(header->size); |
Nathan Williams | 78f857f | 2009-03-25 20:33:42 +1100 | [diff] [blame] | 681 | if (size > (card->buffer_size - sizeof(*header))){ |
| 682 | dev_warn(&card->dev->dev, "Invalid buffer size\n"); |
| 683 | continue; |
| 684 | } |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 685 | |
| 686 | skb = alloc_skb(size + 1, GFP_ATOMIC); |
| 687 | if (!skb) { |
| 688 | if (net_ratelimit()) |
| 689 | dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n"); |
| 690 | continue; |
| 691 | } |
| 692 | |
| 693 | memcpy_fromio(skb_put(skb, size), |
| 694 | RX_BUF(card, port) + sizeof(*header), |
| 695 | size); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 696 | } |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 697 | if (atmdebug) { |
Philip A. Prindeville | 18b429e | 2011-03-30 12:59:26 +0000 | [diff] [blame] | 698 | dev_info(&card->dev->dev, "Received: port %d\n", port); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 699 | dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n", |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 700 | size, le16_to_cpu(header->vpi), |
| 701 | le16_to_cpu(header->vci)); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 702 | print_buffer(skb); |
| 703 | } |
| 704 | |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 705 | switch (le16_to_cpu(header->type)) { |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 706 | case PKT_DATA: |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 707 | vcc = find_vcc(card->atmdev[port], le16_to_cpu(header->vpi), |
| 708 | le16_to_cpu(header->vci)); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 709 | if (!vcc) { |
| 710 | if (net_ratelimit()) |
Philip A. Prindeville | 1e19e65 | 2011-03-30 13:22:45 +0000 | [diff] [blame] | 711 | dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n", |
| 712 | le16_to_cpu(header->vpi), le16_to_cpu(header->vci), |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 713 | port); |
| 714 | continue; |
| 715 | } |
| 716 | atm_charge(vcc, skb->truesize); |
| 717 | vcc->push(vcc, skb); |
| 718 | atomic_inc(&vcc->stats->rx); |
| 719 | break; |
| 720 | |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 721 | case PKT_STATUS: |
David Woodhouse | 95852f4 | 2009-01-30 14:23:52 +1100 | [diff] [blame] | 722 | if (process_status(card, port, skb) && |
| 723 | net_ratelimit()) { |
| 724 | dev_warn(&card->dev->dev, "Bad status packet of %d bytes on port %d:\n", skb->len, port); |
| 725 | print_buffer(skb); |
| 726 | } |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 727 | dev_kfree_skb_any(skb); |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 728 | break; |
| 729 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 730 | case PKT_COMMAND: |
| 731 | default: /* FIXME: Not really, surely? */ |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 732 | if (process_command(card, port, skb)) |
| 733 | break; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 734 | spin_lock(&card->cli_queue_lock); |
| 735 | if (skb_queue_len(&card->cli_queue[port]) > 10) { |
| 736 | if (net_ratelimit()) |
| 737 | dev_warn(&card->dev->dev, "Dropping console response on port %d\n", |
| 738 | port); |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 739 | dev_kfree_skb_any(skb); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 740 | } else |
| 741 | skb_queue_tail(&card->cli_queue[port], skb); |
| 742 | spin_unlock(&card->cli_queue_lock); |
| 743 | break; |
| 744 | } |
| 745 | } |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 746 | /* Allocate RX skbs for any ports which need them */ |
| 747 | if (card->using_dma && card->atmdev[port] && |
| 748 | !card->rx_skb[port]) { |
| 749 | struct sk_buff *skb = alloc_skb(RX_DMA_SIZE, GFP_ATOMIC); |
| 750 | if (skb) { |
| 751 | SKB_CB(skb)->dma_addr = |
| 752 | pci_map_single(card->dev, skb->data, |
| 753 | RX_DMA_SIZE, PCI_DMA_FROMDEVICE); |
| 754 | iowrite32(SKB_CB(skb)->dma_addr, |
| 755 | card->config_regs + RX_DMA_ADDR(port)); |
| 756 | card->rx_skb[port] = skb; |
| 757 | } else { |
| 758 | if (net_ratelimit()) |
| 759 | dev_warn(&card->dev->dev, "Failed to allocate RX skb"); |
| 760 | |
| 761 | /* We'll have to try again later */ |
| 762 | tasklet_schedule(&card->tlet); |
| 763 | } |
| 764 | } |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 765 | } |
| 766 | if (rx_done) |
| 767 | iowrite32(rx_done, card->config_regs + FLAGS_ADDR); |
| 768 | |
| 769 | return; |
| 770 | } |
| 771 | |
| 772 | static struct atm_vcc *find_vcc(struct atm_dev *dev, short vpi, int vci) |
| 773 | { |
| 774 | struct hlist_head *head; |
| 775 | struct atm_vcc *vcc = NULL; |
| 776 | struct hlist_node *node; |
| 777 | struct sock *s; |
| 778 | |
| 779 | read_lock(&vcc_sklist_lock); |
| 780 | head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)]; |
| 781 | sk_for_each(s, node, head) { |
| 782 | vcc = atm_sk(s); |
| 783 | if (vcc->dev == dev && vcc->vci == vci && |
David Woodhouse | 1f6ea6e | 2010-08-07 23:02:59 -0700 | [diff] [blame] | 784 | vcc->vpi == vpi && vcc->qos.rxtp.traffic_class != ATM_NONE && |
| 785 | test_bit(ATM_VF_READY, &vcc->flags)) |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 786 | goto out; |
| 787 | } |
| 788 | vcc = NULL; |
| 789 | out: |
| 790 | read_unlock(&vcc_sklist_lock); |
| 791 | return vcc; |
| 792 | } |
| 793 | |
| 794 | static int list_vccs(int vci) |
| 795 | { |
| 796 | struct hlist_head *head; |
| 797 | struct atm_vcc *vcc; |
| 798 | struct hlist_node *node; |
| 799 | struct sock *s; |
| 800 | int num_found = 0; |
| 801 | int i; |
| 802 | |
| 803 | read_lock(&vcc_sklist_lock); |
| 804 | if (vci != 0){ |
| 805 | head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)]; |
| 806 | sk_for_each(s, node, head) { |
| 807 | num_found ++; |
| 808 | vcc = atm_sk(s); |
| 809 | printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", |
| 810 | vcc->dev->number, |
| 811 | vcc->vpi, |
| 812 | vcc->vci); |
| 813 | } |
| 814 | } else { |
David Woodhouse | 1e615df | 2009-01-27 21:47:47 +1100 | [diff] [blame] | 815 | for(i = 0; i < VCC_HTABLE_SIZE; i++){ |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 816 | head = &vcc_hash[i]; |
| 817 | sk_for_each(s, node, head) { |
| 818 | num_found ++; |
| 819 | vcc = atm_sk(s); |
| 820 | printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n", |
| 821 | vcc->dev->number, |
| 822 | vcc->vpi, |
| 823 | vcc->vci); |
| 824 | } |
| 825 | } |
| 826 | } |
| 827 | read_unlock(&vcc_sklist_lock); |
| 828 | return num_found; |
| 829 | } |
| 830 | |
| 831 | |
| 832 | static int popen(struct atm_vcc *vcc) |
| 833 | { |
| 834 | struct solos_card *card = vcc->dev->dev_data; |
| 835 | struct sk_buff *skb; |
| 836 | struct pkt_hdr *header; |
| 837 | |
David Woodhouse | b28a4b9 | 2009-01-27 21:50:36 +1100 | [diff] [blame] | 838 | if (vcc->qos.aal != ATM_AAL5) { |
| 839 | dev_warn(&card->dev->dev, "Unsupported ATM type %d\n", |
| 840 | vcc->qos.aal); |
| 841 | return -EINVAL; |
| 842 | } |
| 843 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 844 | skb = alloc_skb(sizeof(*header), GFP_ATOMIC); |
Jesper Juhl | da1ab3e | 2011-02-13 10:49:32 +0000 | [diff] [blame] | 845 | if (!skb) { |
| 846 | if (net_ratelimit()) |
| 847 | dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n"); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 848 | return -ENOMEM; |
| 849 | } |
| 850 | header = (void *)skb_put(skb, sizeof(*header)); |
| 851 | |
David Woodhouse | b76811a | 2009-01-27 10:18:51 +1100 | [diff] [blame] | 852 | header->size = cpu_to_le16(0); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 853 | header->vpi = cpu_to_le16(vcc->vpi); |
| 854 | header->vci = cpu_to_le16(vcc->vci); |
| 855 | header->type = cpu_to_le16(PKT_POPEN); |
| 856 | |
| 857 | fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); |
| 858 | |
David Woodhouse | bdc5462 | 2009-01-29 14:37:20 +1100 | [diff] [blame] | 859 | set_bit(ATM_VF_ADDR, &vcc->flags); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 860 | set_bit(ATM_VF_READY, &vcc->flags); |
| 861 | list_vccs(0); |
| 862 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 863 | |
| 864 | return 0; |
| 865 | } |
| 866 | |
| 867 | static void pclose(struct atm_vcc *vcc) |
| 868 | { |
| 869 | struct solos_card *card = vcc->dev->dev_data; |
| 870 | struct sk_buff *skb; |
| 871 | struct pkt_hdr *header; |
| 872 | |
| 873 | skb = alloc_skb(sizeof(*header), GFP_ATOMIC); |
| 874 | if (!skb) { |
| 875 | dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n"); |
| 876 | return; |
| 877 | } |
| 878 | header = (void *)skb_put(skb, sizeof(*header)); |
| 879 | |
David Woodhouse | b76811a | 2009-01-27 10:18:51 +1100 | [diff] [blame] | 880 | header->size = cpu_to_le16(0); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 881 | header->vpi = cpu_to_le16(vcc->vpi); |
| 882 | header->vci = cpu_to_le16(vcc->vci); |
| 883 | header->type = cpu_to_le16(PKT_PCLOSE); |
| 884 | |
| 885 | fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); |
| 886 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 887 | clear_bit(ATM_VF_ADDR, &vcc->flags); |
| 888 | clear_bit(ATM_VF_READY, &vcc->flags); |
| 889 | |
David Woodhouse | 1f6ea6e | 2010-08-07 23:02:59 -0700 | [diff] [blame] | 890 | /* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the |
| 891 | tasklet has finished processing any incoming packets (and, more to |
| 892 | the point, using the vcc pointer). */ |
| 893 | tasklet_unlock_wait(&card->tlet); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 894 | return; |
| 895 | } |
| 896 | |
| 897 | static int print_buffer(struct sk_buff *buf) |
| 898 | { |
| 899 | int len,i; |
| 900 | char msg[500]; |
| 901 | char item[10]; |
| 902 | |
| 903 | len = buf->len; |
| 904 | for (i = 0; i < len; i++){ |
| 905 | if(i % 8 == 0) |
| 906 | sprintf(msg, "%02X: ", i); |
| 907 | |
| 908 | sprintf(item,"%02X ",*(buf->data + i)); |
| 909 | strcat(msg, item); |
| 910 | if(i % 8 == 7) { |
| 911 | sprintf(item, "\n"); |
| 912 | strcat(msg, item); |
| 913 | printk(KERN_DEBUG "%s", msg); |
| 914 | } |
| 915 | } |
| 916 | if (i % 8 != 0) { |
| 917 | sprintf(item, "\n"); |
| 918 | strcat(msg, item); |
| 919 | printk(KERN_DEBUG "%s", msg); |
| 920 | } |
| 921 | printk(KERN_DEBUG "\n"); |
| 922 | |
| 923 | return 0; |
| 924 | } |
| 925 | |
| 926 | static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb, |
| 927 | struct atm_vcc *vcc) |
| 928 | { |
| 929 | int old_len; |
David Woodhouse | f69e417 | 2009-01-29 11:10:58 +1100 | [diff] [blame] | 930 | unsigned long flags; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 931 | |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 932 | SKB_CB(skb)->vcc = vcc; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 933 | |
David Woodhouse | f69e417 | 2009-01-29 11:10:58 +1100 | [diff] [blame] | 934 | spin_lock_irqsave(&card->tx_queue_lock, flags); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 935 | old_len = skb_queue_len(&card->tx_queue[port]); |
| 936 | skb_queue_tail(&card->tx_queue[port], skb); |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 937 | if (!old_len) |
David Woodhouse | f69e417 | 2009-01-29 11:10:58 +1100 | [diff] [blame] | 938 | card->tx_mask |= (1 << port); |
David Woodhouse | f69e417 | 2009-01-29 11:10:58 +1100 | [diff] [blame] | 939 | spin_unlock_irqrestore(&card->tx_queue_lock, flags); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 940 | |
David Woodhouse | f69e417 | 2009-01-29 11:10:58 +1100 | [diff] [blame] | 941 | /* Theoretically we could just schedule the tasklet here, but |
| 942 | that introduces latency we don't want -- it's noticeable */ |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 943 | if (!old_len) |
| 944 | fpga_tx(card); |
| 945 | } |
| 946 | |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 947 | static uint32_t fpga_tx(struct solos_card *card) |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 948 | { |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 949 | uint32_t tx_pending, card_flags; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 950 | uint32_t tx_started = 0; |
| 951 | struct sk_buff *skb; |
| 952 | struct atm_vcc *vcc; |
| 953 | unsigned char port; |
| 954 | unsigned long flags; |
| 955 | |
| 956 | spin_lock_irqsave(&card->tx_lock, flags); |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 957 | |
| 958 | card_flags = ioread32(card->config_regs + FLAGS_ADDR); |
| 959 | /* |
| 960 | * The queue lock is required for _writing_ to tx_mask, but we're |
| 961 | * OK to read it here without locking. The only potential update |
| 962 | * that we could race with is in fpga_queue() where it sets a bit |
| 963 | * for a new port... but it's going to call this function again if |
| 964 | * it's doing that, anyway. |
| 965 | */ |
| 966 | tx_pending = card->tx_mask & ~card_flags; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 967 | |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 968 | for (port = 0; tx_pending; tx_pending >>= 1, port++) { |
| 969 | if (tx_pending & 1) { |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 970 | struct sk_buff *oldskb = card->tx_skb[port]; |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 971 | if (oldskb) |
| 972 | pci_unmap_single(card->dev, SKB_CB(oldskb)->dma_addr, |
| 973 | oldskb->len, PCI_DMA_TODEVICE); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 974 | |
| 975 | spin_lock(&card->tx_queue_lock); |
| 976 | skb = skb_dequeue(&card->tx_queue[port]); |
David Woodhouse | f69e417 | 2009-01-29 11:10:58 +1100 | [diff] [blame] | 977 | if (!skb) |
| 978 | card->tx_mask &= ~(1 << port); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 979 | spin_unlock(&card->tx_queue_lock); |
| 980 | |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 981 | if (skb && !card->using_dma) { |
| 982 | memcpy_toio(TX_BUF(card, port), skb->data, skb->len); |
David Woodhouse | bdc5462 | 2009-01-29 14:37:20 +1100 | [diff] [blame] | 983 | tx_started |= 1 << port; |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 984 | oldskb = skb; /* We're done with this skb already */ |
| 985 | } else if (skb && card->using_dma) { |
| 986 | SKB_CB(skb)->dma_addr = pci_map_single(card->dev, skb->data, |
| 987 | skb->len, PCI_DMA_TODEVICE); |
| 988 | iowrite32(SKB_CB(skb)->dma_addr, |
| 989 | card->config_regs + TX_DMA_ADDR(port)); |
| 990 | } |
| 991 | |
| 992 | if (!oldskb) |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 993 | continue; |
| 994 | |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 995 | /* Clean up and free oldskb now it's gone */ |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 996 | if (atmdebug) { |
Philip A. Prindeville | 18b429e | 2011-03-30 12:59:26 +0000 | [diff] [blame] | 997 | struct pkt_hdr *header = (void *)oldskb->data; |
| 998 | int size = le16_to_cpu(header->size); |
| 999 | |
| 1000 | skb_pull(oldskb, sizeof(*header)); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1001 | dev_info(&card->dev->dev, "Transmitted: port %d\n", |
| 1002 | port); |
Philip A. Prindeville | 18b429e | 2011-03-30 12:59:26 +0000 | [diff] [blame] | 1003 | dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n", |
| 1004 | size, le16_to_cpu(header->vpi), |
| 1005 | le16_to_cpu(header->vci)); |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 1006 | print_buffer(oldskb); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1007 | } |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1008 | |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 1009 | vcc = SKB_CB(oldskb)->vcc; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1010 | |
| 1011 | if (vcc) { |
| 1012 | atomic_inc(&vcc->stats->tx); |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 1013 | solos_pop(vcc, oldskb); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1014 | } else |
David Woodhouse | eaf83e3 | 2009-01-29 10:51:11 +1100 | [diff] [blame] | 1015 | dev_kfree_skb_irq(oldskb); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1016 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1017 | } |
| 1018 | } |
David Woodhouse | bdc5462 | 2009-01-29 14:37:20 +1100 | [diff] [blame] | 1019 | /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */ |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1020 | if (tx_started) |
| 1021 | iowrite32(tx_started, card->config_regs + FLAGS_ADDR); |
| 1022 | |
| 1023 | spin_unlock_irqrestore(&card->tx_lock, flags); |
David Woodhouse | 35c2221 | 2009-01-29 14:08:27 +1100 | [diff] [blame] | 1024 | return card_flags; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | static int psend(struct atm_vcc *vcc, struct sk_buff *skb) |
| 1028 | { |
| 1029 | struct solos_card *card = vcc->dev->dev_data; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1030 | struct pkt_hdr *header; |
David Woodhouse | b76811a | 2009-01-27 10:18:51 +1100 | [diff] [blame] | 1031 | int pktlen; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1032 | |
David Woodhouse | b76811a | 2009-01-27 10:18:51 +1100 | [diff] [blame] | 1033 | pktlen = skb->len; |
| 1034 | if (pktlen > (BUF_SIZE - sizeof(*header))) { |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1035 | dev_warn(&card->dev->dev, "Length of PDU is too large. Dropping PDU.\n"); |
| 1036 | solos_pop(vcc, skb); |
| 1037 | return 0; |
| 1038 | } |
| 1039 | |
| 1040 | if (!skb_clone_writable(skb, sizeof(*header))) { |
| 1041 | int expand_by = 0; |
| 1042 | int ret; |
| 1043 | |
| 1044 | if (skb_headroom(skb) < sizeof(*header)) |
| 1045 | expand_by = sizeof(*header) - skb_headroom(skb); |
| 1046 | |
| 1047 | ret = pskb_expand_head(skb, expand_by, 0, GFP_ATOMIC); |
| 1048 | if (ret) { |
Simon Farnsworth | 4306cad | 2009-01-19 21:19:29 +0000 | [diff] [blame] | 1049 | dev_warn(&card->dev->dev, "pskb_expand_head failed.\n"); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1050 | solos_pop(vcc, skb); |
| 1051 | return ret; |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | header = (void *)skb_push(skb, sizeof(*header)); |
| 1056 | |
David Woodhouse | b76811a | 2009-01-27 10:18:51 +1100 | [diff] [blame] | 1057 | /* This does _not_ include the size of the header */ |
| 1058 | header->size = cpu_to_le16(pktlen); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1059 | header->vpi = cpu_to_le16(vcc->vpi); |
| 1060 | header->vci = cpu_to_le16(vcc->vci); |
| 1061 | header->type = cpu_to_le16(PKT_DATA); |
| 1062 | |
| 1063 | fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, vcc); |
| 1064 | |
| 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | static struct atmdev_ops fpga_ops = { |
| 1069 | .open = popen, |
| 1070 | .close = pclose, |
| 1071 | .ioctl = NULL, |
| 1072 | .getsockopt = NULL, |
| 1073 | .setsockopt = NULL, |
| 1074 | .send = psend, |
| 1075 | .send_oam = NULL, |
| 1076 | .phy_put = NULL, |
| 1077 | .phy_get = NULL, |
| 1078 | .change_qos = NULL, |
| 1079 | .proc_read = NULL, |
| 1080 | .owner = THIS_MODULE |
| 1081 | }; |
| 1082 | |
| 1083 | static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id) |
| 1084 | { |
David Woodhouse | cd5549e | 2009-01-30 14:26:37 +1100 | [diff] [blame] | 1085 | int err; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1086 | uint16_t fpga_ver; |
| 1087 | uint8_t major_ver, minor_ver; |
| 1088 | uint32_t data32; |
| 1089 | struct solos_card *card; |
| 1090 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1091 | card = kzalloc(sizeof(*card), GFP_KERNEL); |
| 1092 | if (!card) |
| 1093 | return -ENOMEM; |
| 1094 | |
| 1095 | card->dev = dev; |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1096 | init_waitqueue_head(&card->fw_wq); |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 1097 | init_waitqueue_head(&card->param_wq); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1098 | |
| 1099 | err = pci_enable_device(dev); |
| 1100 | if (err) { |
| 1101 | dev_warn(&dev->dev, "Failed to enable PCI device\n"); |
| 1102 | goto out; |
| 1103 | } |
| 1104 | |
Yang Hongyang | e930438 | 2009-04-13 14:40:14 -0700 | [diff] [blame] | 1105 | err = pci_set_dma_mask(dev, DMA_BIT_MASK(32)); |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 1106 | if (err) { |
| 1107 | dev_warn(&dev->dev, "Failed to set 32-bit DMA mask\n"); |
| 1108 | goto out; |
| 1109 | } |
| 1110 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1111 | err = pci_request_regions(dev, "solos"); |
| 1112 | if (err) { |
| 1113 | dev_warn(&dev->dev, "Failed to request regions\n"); |
| 1114 | goto out; |
| 1115 | } |
| 1116 | |
| 1117 | card->config_regs = pci_iomap(dev, 0, CONFIG_RAM_SIZE); |
| 1118 | if (!card->config_regs) { |
| 1119 | dev_warn(&dev->dev, "Failed to ioremap config registers\n"); |
| 1120 | goto out_release_regions; |
| 1121 | } |
| 1122 | card->buffers = pci_iomap(dev, 1, DATA_RAM_SIZE); |
| 1123 | if (!card->buffers) { |
| 1124 | dev_warn(&dev->dev, "Failed to ioremap data buffers\n"); |
| 1125 | goto out_unmap_config; |
| 1126 | } |
| 1127 | |
David Woodhouse | cc3657e | 2009-01-30 14:23:22 +1100 | [diff] [blame] | 1128 | if (reset) { |
| 1129 | iowrite32(1, card->config_regs + FPGA_MODE); |
| 1130 | data32 = ioread32(card->config_regs + FPGA_MODE); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1131 | |
David Woodhouse | cc3657e | 2009-01-30 14:23:22 +1100 | [diff] [blame] | 1132 | iowrite32(0, card->config_regs + FPGA_MODE); |
| 1133 | data32 = ioread32(card->config_regs + FPGA_MODE); |
| 1134 | } |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1135 | |
| 1136 | data32 = ioread32(card->config_regs + FPGA_VER); |
| 1137 | fpga_ver = (data32 & 0x0000FFFF); |
| 1138 | major_ver = ((data32 & 0xFF000000) >> 24); |
| 1139 | minor_ver = ((data32 & 0x00FF0000) >> 16); |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 1140 | card->fpga_version = FPGA_VERSION(major_ver,minor_ver); |
| 1141 | if (card->fpga_version > LEGACY_BUFFERS) |
| 1142 | card->buffer_size = BUF_SIZE; |
| 1143 | else |
| 1144 | card->buffer_size = OLD_BUF_SIZE; |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1145 | dev_info(&dev->dev, "Solos FPGA Version %d.%02d svn-%d\n", |
| 1146 | major_ver, minor_ver, fpga_ver); |
| 1147 | |
David Woodhouse | 3ce1227 | 2010-11-01 10:35:28 +0000 | [diff] [blame] | 1148 | if (fpga_ver < 37 && (fpga_upgrade || firmware_upgrade || |
| 1149 | db_fpga_upgrade || db_firmware_upgrade)) { |
| 1150 | dev_warn(&dev->dev, |
| 1151 | "FPGA too old; cannot upgrade flash. Use JTAG.\n"); |
| 1152 | fpga_upgrade = firmware_upgrade = 0; |
| 1153 | db_fpga_upgrade = db_firmware_upgrade = 0; |
| 1154 | } |
| 1155 | |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 1156 | if (card->fpga_version >= DMA_SUPPORTED){ |
David Woodhouse | 9093723 | 2009-01-28 16:46:56 +1100 | [diff] [blame] | 1157 | card->using_dma = 1; |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 1158 | } else { |
| 1159 | card->using_dma = 0; |
David Woodhouse | eab50f7 | 2009-01-30 14:27:26 +1100 | [diff] [blame] | 1160 | /* Set RX empty flag for all ports */ |
| 1161 | iowrite32(0xF0, card->config_regs + FLAGS_ADDR); |
| 1162 | } |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1163 | |
Nathan Williams | 0fc36aa | 2009-02-07 10:19:13 +1100 | [diff] [blame] | 1164 | data32 = ioread32(card->config_regs + PORTS); |
| 1165 | card->nr_ports = (data32 & 0x000000FF); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1166 | |
| 1167 | pci_set_drvdata(dev, card); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1168 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1169 | tasklet_init(&card->tlet, solos_bh, (unsigned long)card); |
| 1170 | spin_lock_init(&card->tx_lock); |
| 1171 | spin_lock_init(&card->tx_queue_lock); |
| 1172 | spin_lock_init(&card->cli_queue_lock); |
David Woodhouse | 01e2ffa | 2009-01-27 16:20:04 +1100 | [diff] [blame] | 1173 | spin_lock_init(&card->param_queue_lock); |
| 1174 | INIT_LIST_HEAD(&card->param_queue); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1175 | |
David Woodhouse | fcd8266 | 2009-01-29 11:29:12 +1100 | [diff] [blame] | 1176 | err = request_irq(dev->irq, solos_irq, IRQF_SHARED, |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1177 | "solos-pci", card); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1178 | if (err) { |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1179 | dev_dbg(&card->dev->dev, "Failed to request interrupt IRQ: %d\n", dev->irq); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1180 | goto out_unmap_both; |
| 1181 | } |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1182 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1183 | iowrite32(1, card->config_regs + IRQ_EN_ADDR); |
| 1184 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1185 | if (fpga_upgrade) |
| 1186 | flash_upgrade(card, 0); |
| 1187 | |
| 1188 | if (firmware_upgrade) |
| 1189 | flash_upgrade(card, 1); |
| 1190 | |
Nathan Williams | 4dbedf4 | 2009-03-25 20:27:37 +1100 | [diff] [blame] | 1191 | if (db_fpga_upgrade) |
| 1192 | flash_upgrade(card, 2); |
| 1193 | |
| 1194 | if (db_firmware_upgrade) |
| 1195 | flash_upgrade(card, 3); |
| 1196 | |
Dan Williams | d9ca676 | 2010-12-08 19:40:47 +0000 | [diff] [blame] | 1197 | err = atm_init(card, &dev->dev); |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1198 | if (err) |
| 1199 | goto out_free_irq; |
| 1200 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1201 | return 0; |
| 1202 | |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1203 | out_free_irq: |
| 1204 | iowrite32(0, card->config_regs + IRQ_EN_ADDR); |
| 1205 | free_irq(dev->irq, card); |
| 1206 | tasklet_kill(&card->tlet); |
| 1207 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1208 | out_unmap_both: |
David Woodhouse | fa755b9 | 2009-01-27 14:16:12 +1100 | [diff] [blame] | 1209 | pci_set_drvdata(dev, NULL); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1210 | pci_iounmap(dev, card->config_regs); |
| 1211 | out_unmap_config: |
| 1212 | pci_iounmap(dev, card->buffers); |
| 1213 | out_release_regions: |
| 1214 | pci_release_regions(dev); |
| 1215 | out: |
Julia Lawall | bc111d5 | 2009-02-08 17:00:02 -0800 | [diff] [blame] | 1216 | kfree(card); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1217 | return err; |
| 1218 | } |
| 1219 | |
Dan Williams | d9ca676 | 2010-12-08 19:40:47 +0000 | [diff] [blame] | 1220 | static int atm_init(struct solos_card *card, struct device *parent) |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1221 | { |
| 1222 | int i; |
| 1223 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1224 | for (i = 0; i < card->nr_ports; i++) { |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 1225 | struct sk_buff *skb; |
| 1226 | struct pkt_hdr *header; |
| 1227 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1228 | skb_queue_head_init(&card->tx_queue[i]); |
| 1229 | skb_queue_head_init(&card->cli_queue[i]); |
| 1230 | |
Dan Williams | d9ca676 | 2010-12-08 19:40:47 +0000 | [diff] [blame] | 1231 | card->atmdev[i] = atm_dev_register("solos-pci", parent, &fpga_ops, -1, NULL); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1232 | if (!card->atmdev[i]) { |
| 1233 | dev_err(&card->dev->dev, "Could not register ATM device %d\n", i); |
| 1234 | atm_remove(card); |
| 1235 | return -ENODEV; |
| 1236 | } |
| 1237 | if (device_create_file(&card->atmdev[i]->class_dev, &dev_attr_console)) |
| 1238 | dev_err(&card->dev->dev, "Could not register console for ATM device %d\n", i); |
David Woodhouse | d057f0a | 2009-01-27 16:52:07 +1100 | [diff] [blame] | 1239 | if (sysfs_create_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group)) |
| 1240 | dev_err(&card->dev->dev, "Could not register parameter group for ATM device %d\n", i); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1241 | |
| 1242 | dev_info(&card->dev->dev, "Registered ATM device %d\n", card->atmdev[i]->number); |
| 1243 | |
| 1244 | card->atmdev[i]->ci_range.vpi_bits = 8; |
| 1245 | card->atmdev[i]->ci_range.vci_bits = 16; |
| 1246 | card->atmdev[i]->dev_data = card; |
| 1247 | card->atmdev[i]->phy_data = (void *)(unsigned long)i; |
Philip A. Prindeville | c031235 | 2011-03-30 13:17:04 +0000 | [diff] [blame] | 1248 | atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND); |
David Woodhouse | 87ebb18 | 2009-01-27 20:02:30 +1100 | [diff] [blame] | 1249 | |
| 1250 | skb = alloc_skb(sizeof(*header), GFP_ATOMIC); |
| 1251 | if (!skb) { |
| 1252 | dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n"); |
| 1253 | continue; |
| 1254 | } |
| 1255 | |
| 1256 | header = (void *)skb_put(skb, sizeof(*header)); |
| 1257 | |
| 1258 | header->size = cpu_to_le16(0); |
| 1259 | header->vpi = cpu_to_le16(0); |
| 1260 | header->vci = cpu_to_le16(0); |
| 1261 | header->type = cpu_to_le16(PKT_STATUS); |
| 1262 | |
| 1263 | fpga_queue(card, i, skb, NULL); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1264 | } |
| 1265 | return 0; |
| 1266 | } |
| 1267 | |
| 1268 | static void atm_remove(struct solos_card *card) |
| 1269 | { |
| 1270 | int i; |
| 1271 | |
| 1272 | for (i = 0; i < card->nr_ports; i++) { |
| 1273 | if (card->atmdev[i]) { |
David Woodhouse | 97d759d | 2009-03-17 14:59:34 +0000 | [diff] [blame] | 1274 | struct sk_buff *skb; |
| 1275 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1276 | dev_info(&card->dev->dev, "Unregistering ATM device %d\n", card->atmdev[i]->number); |
David Woodhouse | c0fe302 | 2009-01-28 14:34:34 +1100 | [diff] [blame] | 1277 | |
| 1278 | sysfs_remove_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1279 | atm_dev_deregister(card->atmdev[i]); |
David Woodhouse | 97d759d | 2009-03-17 14:59:34 +0000 | [diff] [blame] | 1280 | |
| 1281 | skb = card->rx_skb[i]; |
| 1282 | if (skb) { |
| 1283 | pci_unmap_single(card->dev, SKB_CB(skb)->dma_addr, |
| 1284 | RX_DMA_SIZE, PCI_DMA_FROMDEVICE); |
| 1285 | dev_kfree_skb(skb); |
| 1286 | } |
| 1287 | skb = card->tx_skb[i]; |
| 1288 | if (skb) { |
| 1289 | pci_unmap_single(card->dev, SKB_CB(skb)->dma_addr, |
| 1290 | skb->len, PCI_DMA_TODEVICE); |
| 1291 | dev_kfree_skb(skb); |
| 1292 | } |
| 1293 | while ((skb = skb_dequeue(&card->tx_queue[i]))) |
| 1294 | dev_kfree_skb(skb); |
| 1295 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1296 | } |
| 1297 | } |
| 1298 | } |
| 1299 | |
| 1300 | static void fpga_remove(struct pci_dev *dev) |
| 1301 | { |
| 1302 | struct solos_card *card = pci_get_drvdata(dev); |
David Woodhouse | 97d759d | 2009-03-17 14:59:34 +0000 | [diff] [blame] | 1303 | |
| 1304 | /* Disable IRQs */ |
| 1305 | iowrite32(0, card->config_regs + IRQ_EN_ADDR); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1306 | |
David Woodhouse | 97d759d | 2009-03-17 14:59:34 +0000 | [diff] [blame] | 1307 | /* Reset FPGA */ |
| 1308 | iowrite32(1, card->config_regs + FPGA_MODE); |
| 1309 | (void)ioread32(card->config_regs + FPGA_MODE); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1310 | |
| 1311 | atm_remove(card); |
| 1312 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1313 | free_irq(dev->irq, card); |
| 1314 | tasklet_kill(&card->tlet); |
| 1315 | |
David Woodhouse | 97d759d | 2009-03-17 14:59:34 +0000 | [diff] [blame] | 1316 | /* Release device from reset */ |
| 1317 | iowrite32(0, card->config_regs + FPGA_MODE); |
| 1318 | (void)ioread32(card->config_regs + FPGA_MODE); |
| 1319 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1320 | pci_iounmap(dev, card->buffers); |
| 1321 | pci_iounmap(dev, card->config_regs); |
| 1322 | |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1323 | pci_release_regions(dev); |
| 1324 | pci_disable_device(dev); |
| 1325 | |
| 1326 | pci_set_drvdata(dev, NULL); |
| 1327 | kfree(card); |
David Woodhouse | 9c54004 | 2008-12-23 04:09:02 +0000 | [diff] [blame] | 1328 | } |
| 1329 | |
| 1330 | static struct pci_device_id fpga_pci_tbl[] __devinitdata = { |
| 1331 | { 0x10ee, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
| 1332 | { 0, } |
| 1333 | }; |
| 1334 | |
| 1335 | MODULE_DEVICE_TABLE(pci,fpga_pci_tbl); |
| 1336 | |
| 1337 | static struct pci_driver fpga_driver = { |
| 1338 | .name = "solos", |
| 1339 | .id_table = fpga_pci_tbl, |
| 1340 | .probe = fpga_probe, |
| 1341 | .remove = fpga_remove, |
| 1342 | }; |
| 1343 | |
| 1344 | |
| 1345 | static int __init solos_pci_init(void) |
| 1346 | { |
| 1347 | printk(KERN_INFO "Solos PCI Driver Version %s\n", VERSION); |
| 1348 | return pci_register_driver(&fpga_driver); |
| 1349 | } |
| 1350 | |
| 1351 | static void __exit solos_pci_exit(void) |
| 1352 | { |
| 1353 | pci_unregister_driver(&fpga_driver); |
| 1354 | printk(KERN_INFO "Solos PCI Driver %s Unloaded\n", VERSION); |
| 1355 | } |
| 1356 | |
| 1357 | module_init(solos_pci_init); |
| 1358 | module_exit(solos_pci_exit); |