2008-12-23 05:09:02 +01:00
|
|
|
/*
|
|
|
|
* Driver for the Solos PCI ADSL2+ card, designed to support Linux by
|
|
|
|
* Traverse Technologies -- http://www.traverse.com.au/
|
|
|
|
* Xrio Limited -- http://www.xrio.com/
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright © 2008 Traverse Technologies
|
|
|
|
* Copyright © 2008 Intel Corporation
|
|
|
|
*
|
|
|
|
* Authors: Nathan Williams <nathan@traverse.com.au>
|
|
|
|
* David Woodhouse <dwmw2@infradead.org>
|
2009-01-21 21:45:49 +01:00
|
|
|
* Treker Chen <treker@xrio.com>
|
2008-12-23 05:09:02 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEBUG
|
|
|
|
#define VERBOSE_DEBUG
|
|
|
|
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/atm.h>
|
|
|
|
#include <linux/atmdev.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/kobject.h>
|
2009-01-21 21:45:49 +01:00
|
|
|
#include <linux/firmware.h>
|
2009-01-27 06:20:04 +01:00
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/swab.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2012-12-19 12:01:20 +01:00
|
|
|
#define VERSION "1.04"
|
|
|
|
#define DRIVER_VERSION 0x01
|
2008-12-23 05:09:02 +01:00
|
|
|
#define PTAG "solos-pci"
|
|
|
|
|
|
|
|
#define CONFIG_RAM_SIZE 128
|
|
|
|
#define FLAGS_ADDR 0x7C
|
|
|
|
#define IRQ_EN_ADDR 0x78
|
|
|
|
#define FPGA_VER 0x74
|
|
|
|
#define IRQ_CLEAR 0x70
|
2009-01-21 21:45:49 +01:00
|
|
|
#define WRITE_FLASH 0x6C
|
|
|
|
#define PORTS 0x68
|
|
|
|
#define FLASH_BLOCK 0x64
|
|
|
|
#define FLASH_BUSY 0x60
|
|
|
|
#define FPGA_MODE 0x5C
|
|
|
|
#define FLASH_MODE 0x58
|
2012-12-19 12:01:18 +01:00
|
|
|
#define GPIO_STATUS 0x54
|
2012-12-19 12:01:20 +01:00
|
|
|
#define DRIVER_VER 0x50
|
2009-01-28 06:46:56 +01:00
|
|
|
#define TX_DMA_ADDR(port) (0x40 + (4 * (port)))
|
|
|
|
#define RX_DMA_ADDR(port) (0x30 + (4 * (port)))
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
#define DATA_RAM_SIZE 32768
|
2009-03-25 10:27:37 +01:00
|
|
|
#define BUF_SIZE 2048
|
|
|
|
#define OLD_BUF_SIZE 4096 /* For FPGA versions <= 2*/
|
2012-12-19 12:01:20 +01:00
|
|
|
/* Old boards use ATMEL AD45DB161D flash */
|
|
|
|
#define ATMEL_FPGA_PAGE 528 /* FPGA flash page size*/
|
|
|
|
#define ATMEL_SOLOS_PAGE 512 /* Solos flash page size*/
|
|
|
|
#define ATMEL_FPGA_BLOCK (ATMEL_FPGA_PAGE * 8) /* FPGA block size*/
|
|
|
|
#define ATMEL_SOLOS_BLOCK (ATMEL_SOLOS_PAGE * 8) /* Solos block size*/
|
|
|
|
/* Current boards use M25P/M25PE SPI flash */
|
|
|
|
#define SPI_FLASH_BLOCK (256 * 64)
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-03-25 10:27:37 +01:00
|
|
|
#define RX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2)
|
|
|
|
#define TX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2 + (card->buffer_size))
|
|
|
|
#define FLASH_BUF ((card->buffers) + 4*(card->buffer_size)*2)
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-29 00:51:11 +01:00
|
|
|
#define RX_DMA_SIZE 2048
|
|
|
|
|
2009-03-25 10:27:37 +01:00
|
|
|
#define FPGA_VERSION(a,b) (((a) << 8) + (b))
|
|
|
|
#define LEGACY_BUFFERS 2
|
|
|
|
#define DMA_SUPPORTED 4
|
|
|
|
|
2009-01-30 04:23:22 +01:00
|
|
|
static int reset = 0;
|
2008-12-23 05:09:02 +01:00
|
|
|
static int atmdebug = 0;
|
2009-01-21 21:45:49 +01:00
|
|
|
static int firmware_upgrade = 0;
|
|
|
|
static int fpga_upgrade = 0;
|
2009-03-25 10:27:37 +01:00
|
|
|
static int db_firmware_upgrade = 0;
|
|
|
|
static int db_fpga_upgrade = 0;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
struct pkt_hdr {
|
|
|
|
__le16 size;
|
|
|
|
__le16 vpi;
|
|
|
|
__le16 vci;
|
|
|
|
__le16 type;
|
|
|
|
};
|
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
struct solos_skb_cb {
|
|
|
|
struct atm_vcc *vcc;
|
|
|
|
uint32_t dma_addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define SKB_CB(skb) ((struct solos_skb_cb *)skb->cb)
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
#define PKT_DATA 0
|
|
|
|
#define PKT_COMMAND 1
|
|
|
|
#define PKT_POPEN 3
|
|
|
|
#define PKT_PCLOSE 4
|
2009-01-27 10:02:30 +01:00
|
|
|
#define PKT_STATUS 5
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
struct solos_card {
|
|
|
|
void __iomem *config_regs;
|
|
|
|
void __iomem *buffers;
|
|
|
|
int nr_ports;
|
2009-01-29 01:10:58 +01:00
|
|
|
int tx_mask;
|
2008-12-23 05:09:02 +01:00
|
|
|
struct pci_dev *dev;
|
|
|
|
struct atm_dev *atmdev[4];
|
|
|
|
struct tasklet_struct tlet;
|
|
|
|
spinlock_t tx_lock;
|
|
|
|
spinlock_t tx_queue_lock;
|
|
|
|
spinlock_t cli_queue_lock;
|
2009-01-27 06:20:04 +01:00
|
|
|
spinlock_t param_queue_lock;
|
|
|
|
struct list_head param_queue;
|
2008-12-23 05:09:02 +01:00
|
|
|
struct sk_buff_head tx_queue[4];
|
|
|
|
struct sk_buff_head cli_queue[4];
|
2009-01-28 06:46:56 +01:00
|
|
|
struct sk_buff *tx_skb[4];
|
|
|
|
struct sk_buff *rx_skb[4];
|
2012-12-19 12:01:21 +01:00
|
|
|
unsigned char *dma_bounce;
|
2009-01-27 06:20:04 +01:00
|
|
|
wait_queue_head_t param_wq;
|
2009-01-27 04:16:12 +01:00
|
|
|
wait_queue_head_t fw_wq;
|
2009-01-28 06:46:56 +01:00
|
|
|
int using_dma;
|
2012-12-19 12:01:21 +01:00
|
|
|
int dma_alignment;
|
2009-03-25 10:27:37 +01:00
|
|
|
int fpga_version;
|
|
|
|
int buffer_size;
|
2012-12-19 12:01:20 +01:00
|
|
|
int atmel_flash;
|
2008-12-23 05:09:02 +01:00
|
|
|
};
|
|
|
|
|
2009-01-27 06:20:04 +01:00
|
|
|
|
|
|
|
struct solos_param {
|
|
|
|
struct list_head list;
|
|
|
|
pid_t pid;
|
|
|
|
int port;
|
|
|
|
struct sk_buff *response;
|
2008-12-23 05:09:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define SOLOS_CHAN(atmdev) ((int)(unsigned long)(atmdev)->phy_data)
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Traverse Technologies <support@traverse.com.au>");
|
|
|
|
MODULE_DESCRIPTION("Solos PCI driver");
|
|
|
|
MODULE_VERSION(VERSION);
|
|
|
|
MODULE_LICENSE("GPL");
|
2009-11-07 12:40:32 +01:00
|
|
|
MODULE_FIRMWARE("solos-FPGA.bin");
|
|
|
|
MODULE_FIRMWARE("solos-Firmware.bin");
|
|
|
|
MODULE_FIRMWARE("solos-db-FPGA.bin");
|
2009-01-30 04:23:22 +01:00
|
|
|
MODULE_PARM_DESC(reset, "Reset Solos chips on startup");
|
2008-12-23 05:09:02 +01:00
|
|
|
MODULE_PARM_DESC(atmdebug, "Print ATM data");
|
2009-01-21 21:45:49 +01:00
|
|
|
MODULE_PARM_DESC(firmware_upgrade, "Initiate Solos firmware upgrade");
|
|
|
|
MODULE_PARM_DESC(fpga_upgrade, "Initiate FPGA upgrade");
|
2009-03-25 10:27:37 +01:00
|
|
|
MODULE_PARM_DESC(db_firmware_upgrade, "Initiate daughter board Solos firmware upgrade");
|
|
|
|
MODULE_PARM_DESC(db_fpga_upgrade, "Initiate daughter board FPGA upgrade");
|
2009-01-30 04:23:22 +01:00
|
|
|
module_param(reset, int, 0444);
|
2009-01-19 22:19:29 +01:00
|
|
|
module_param(atmdebug, int, 0644);
|
2009-01-21 21:45:49 +01:00
|
|
|
module_param(firmware_upgrade, int, 0444);
|
|
|
|
module_param(fpga_upgrade, int, 0444);
|
2009-03-25 10:27:37 +01:00
|
|
|
module_param(db_firmware_upgrade, int, 0444);
|
|
|
|
module_param(db_fpga_upgrade, int, 0444);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb,
|
|
|
|
struct atm_vcc *vcc);
|
2009-01-29 04:08:27 +01:00
|
|
|
static uint32_t fpga_tx(struct solos_card *);
|
2008-12-23 05:09:02 +01:00
|
|
|
static irqreturn_t solos_irq(int irq, void *dev_id);
|
|
|
|
static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci);
|
2010-12-08 20:40:47 +01:00
|
|
|
static int atm_init(struct solos_card *, struct device *);
|
2008-12-23 05:09:02 +01:00
|
|
|
static void atm_remove(struct solos_card *);
|
|
|
|
static int send_command(struct solos_card *card, int dev, const char *buf, size_t size);
|
|
|
|
static void solos_bh(unsigned long);
|
|
|
|
static int print_buffer(struct sk_buff *buf);
|
|
|
|
|
|
|
|
static inline void solos_pop(struct atm_vcc *vcc, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
if (vcc->pop)
|
|
|
|
vcc->pop(vcc, skb);
|
|
|
|
else
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
|
|
|
|
2009-01-27 06:20:04 +01:00
|
|
|
static ssize_t solos_param_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
|
|
|
|
struct solos_card *card = atmdev->dev_data;
|
|
|
|
struct solos_param prm;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct pkt_hdr *header;
|
|
|
|
int buflen;
|
|
|
|
|
|
|
|
buflen = strlen(attr->attr.name) + 10;
|
|
|
|
|
2009-01-28 00:39:23 +01:00
|
|
|
skb = alloc_skb(sizeof(*header) + buflen, GFP_KERNEL);
|
2009-01-27 06:20:04 +01:00
|
|
|
if (!skb) {
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_show()\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:21 +02:00
|
|
|
header = skb_put(skb, sizeof(*header));
|
2009-01-27 06:20:04 +01:00
|
|
|
|
|
|
|
buflen = snprintf((void *)&header[1], buflen - 1,
|
|
|
|
"L%05d\n%s\n", current->pid, attr->attr.name);
|
|
|
|
skb_put(skb, buflen);
|
|
|
|
|
|
|
|
header->size = cpu_to_le16(buflen);
|
|
|
|
header->vpi = cpu_to_le16(0);
|
|
|
|
header->vci = cpu_to_le16(0);
|
|
|
|
header->type = cpu_to_le16(PKT_COMMAND);
|
|
|
|
|
|
|
|
prm.pid = current->pid;
|
|
|
|
prm.response = NULL;
|
|
|
|
prm.port = SOLOS_CHAN(atmdev);
|
|
|
|
|
|
|
|
spin_lock_irq(&card->param_queue_lock);
|
|
|
|
list_add(&prm.list, &card->param_queue);
|
|
|
|
spin_unlock_irq(&card->param_queue_lock);
|
|
|
|
|
|
|
|
fpga_queue(card, prm.port, skb, NULL);
|
|
|
|
|
|
|
|
wait_event_timeout(card->param_wq, prm.response, 5 * HZ);
|
|
|
|
|
|
|
|
spin_lock_irq(&card->param_queue_lock);
|
|
|
|
list_del(&prm.list);
|
|
|
|
spin_unlock_irq(&card->param_queue_lock);
|
|
|
|
|
|
|
|
if (!prm.response)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
buflen = prm.response->len;
|
|
|
|
memcpy(buf, prm.response->data, buflen);
|
|
|
|
kfree_skb(prm.response);
|
|
|
|
|
|
|
|
return buflen;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t solos_param_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
|
|
|
|
struct solos_card *card = atmdev->dev_data;
|
|
|
|
struct solos_param prm;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct pkt_hdr *header;
|
|
|
|
int buflen;
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
buflen = strlen(attr->attr.name) + 11 + count;
|
|
|
|
|
2009-01-28 00:39:23 +01:00
|
|
|
skb = alloc_skb(sizeof(*header) + buflen, GFP_KERNEL);
|
2009-01-27 06:20:04 +01:00
|
|
|
if (!skb) {
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_store()\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:21 +02:00
|
|
|
header = skb_put(skb, sizeof(*header));
|
2009-01-27 06:20:04 +01:00
|
|
|
|
|
|
|
buflen = snprintf((void *)&header[1], buflen - 1,
|
|
|
|
"L%05d\n%s\n%s\n", current->pid, attr->attr.name, buf);
|
|
|
|
|
|
|
|
skb_put(skb, buflen);
|
|
|
|
header->size = cpu_to_le16(buflen);
|
|
|
|
header->vpi = cpu_to_le16(0);
|
|
|
|
header->vci = cpu_to_le16(0);
|
|
|
|
header->type = cpu_to_le16(PKT_COMMAND);
|
|
|
|
|
|
|
|
prm.pid = current->pid;
|
|
|
|
prm.response = NULL;
|
|
|
|
prm.port = SOLOS_CHAN(atmdev);
|
|
|
|
|
|
|
|
spin_lock_irq(&card->param_queue_lock);
|
|
|
|
list_add(&prm.list, &card->param_queue);
|
|
|
|
spin_unlock_irq(&card->param_queue_lock);
|
|
|
|
|
|
|
|
fpga_queue(card, prm.port, skb, NULL);
|
|
|
|
|
|
|
|
wait_event_timeout(card->param_wq, prm.response, 5 * HZ);
|
|
|
|
|
|
|
|
spin_lock_irq(&card->param_queue_lock);
|
|
|
|
list_del(&prm.list);
|
|
|
|
spin_unlock_irq(&card->param_queue_lock);
|
|
|
|
|
|
|
|
skb = prm.response;
|
|
|
|
|
|
|
|
if (!skb)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
buflen = skb->len;
|
|
|
|
|
|
|
|
/* Sometimes it has a newline, sometimes it doesn't. */
|
|
|
|
if (skb->data[buflen - 1] == '\n')
|
|
|
|
buflen--;
|
|
|
|
|
|
|
|
if (buflen == 2 && !strncmp(skb->data, "OK", 2))
|
|
|
|
ret = count;
|
|
|
|
else if (buflen == 5 && !strncmp(skb->data, "ERROR", 5))
|
|
|
|
ret = -EIO;
|
|
|
|
else {
|
|
|
|
/* We know we have enough space allocated for this; we allocated
|
|
|
|
it ourselves */
|
|
|
|
skb->data[buflen] = 0;
|
|
|
|
|
|
|
|
dev_warn(&card->dev->dev, "Unexpected parameter response: '%s'\n",
|
|
|
|
skb->data);
|
|
|
|
ret = -EIO;
|
|
|
|
}
|
|
|
|
kfree_skb(skb);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-01-27 10:02:30 +01:00
|
|
|
static char *next_string(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
char *this = skb->data;
|
2009-01-29 02:17:09 +01:00
|
|
|
|
|
|
|
for (i = 0; i < skb->len; i++) {
|
2009-01-27 10:02:30 +01:00
|
|
|
if (this[i] == '\n') {
|
|
|
|
this[i] = 0;
|
2009-01-29 02:17:09 +01:00
|
|
|
skb_pull(skb, i + 1);
|
2009-01-27 10:02:30 +01:00
|
|
|
return this;
|
|
|
|
}
|
2009-01-29 02:17:09 +01:00
|
|
|
if (!isprint(this[i]))
|
|
|
|
return NULL;
|
2009-01-27 10:02:30 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Status packet has fields separated by \n, starting with a version number
|
|
|
|
* for the information therein. Fields are....
|
|
|
|
*
|
|
|
|
* packet version
|
|
|
|
* RxBitRate (version >= 1)
|
2009-01-30 04:31:36 +01:00
|
|
|
* TxBitRate (version >= 1)
|
2009-01-27 10:02:30 +01:00
|
|
|
* State (version >= 1)
|
2009-01-30 04:31:36 +01:00
|
|
|
* LocalSNRMargin (version >= 1)
|
|
|
|
* LocalLineAttn (version >= 1)
|
2009-01-27 10:02:30 +01:00
|
|
|
*/
|
|
|
|
static int process_status(struct solos_card *card, int port, struct sk_buff *skb)
|
|
|
|
{
|
2015-12-04 08:43:19 +01:00
|
|
|
char *str, *state_str, *snr, *attn;
|
|
|
|
int ver, rate_up, rate_down, err;
|
2009-01-27 10:02:30 +01:00
|
|
|
|
|
|
|
if (!card->atmdev[port])
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
str = next_string(skb);
|
|
|
|
if (!str)
|
|
|
|
return -EIO;
|
|
|
|
|
2015-12-04 08:43:19 +01:00
|
|
|
err = kstrtoint(str, 10, &ver);
|
|
|
|
if (err) {
|
|
|
|
dev_warn(&card->dev->dev, "Unexpected status interrupt version\n");
|
|
|
|
return err;
|
|
|
|
}
|
2009-01-27 10:02:30 +01:00
|
|
|
if (ver < 1) {
|
|
|
|
dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n",
|
|
|
|
ver);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = next_string(skb);
|
2009-01-29 02:17:09 +01:00
|
|
|
if (!str)
|
|
|
|
return -EIO;
|
2009-01-30 04:23:52 +01:00
|
|
|
if (!strcmp(str, "ERROR")) {
|
|
|
|
dev_dbg(&card->dev->dev, "Status packet indicated Solos error on port %d (starting up?)\n",
|
|
|
|
port);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-04 08:43:19 +01:00
|
|
|
err = kstrtoint(str, 10, &rate_down);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-01-27 10:02:30 +01:00
|
|
|
|
|
|
|
str = next_string(skb);
|
2009-01-29 02:17:09 +01:00
|
|
|
if (!str)
|
|
|
|
return -EIO;
|
2015-12-04 08:43:19 +01:00
|
|
|
err = kstrtoint(str, 10, &rate_up);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-01-27 10:02:30 +01:00
|
|
|
|
2009-01-28 00:22:57 +01:00
|
|
|
state_str = next_string(skb);
|
2009-01-29 02:17:09 +01:00
|
|
|
if (!state_str)
|
|
|
|
return -EIO;
|
2009-01-30 04:31:36 +01:00
|
|
|
|
|
|
|
/* Anything but 'Showtime' is down */
|
|
|
|
if (strcmp(state_str, "Showtime")) {
|
2010-07-08 22:55:34 +02:00
|
|
|
atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_LOST);
|
2009-01-30 04:31:36 +01:00
|
|
|
dev_info(&card->dev->dev, "Port %d: %s\n", port, state_str);
|
|
|
|
return 0;
|
2009-01-27 11:47:47 +01:00
|
|
|
}
|
2009-01-27 10:02:30 +01:00
|
|
|
|
2009-01-30 04:31:36 +01:00
|
|
|
snr = next_string(skb);
|
2009-07-27 20:38:52 +02:00
|
|
|
if (!snr)
|
2009-01-30 04:31:36 +01:00
|
|
|
return -EIO;
|
|
|
|
attn = next_string(skb);
|
|
|
|
if (!attn)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
dev_info(&card->dev->dev, "Port %d: %s @%d/%d kb/s%s%s%s%s\n",
|
|
|
|
port, state_str, rate_down/1000, rate_up/1000,
|
|
|
|
snr[0]?", SNR ":"", snr, attn[0]?", Attn ":"", attn);
|
|
|
|
|
2009-01-29 02:17:09 +01:00
|
|
|
card->atmdev[port]->link_rate = rate_down / 424;
|
2010-07-08 22:55:34 +02:00
|
|
|
atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_FOUND);
|
2009-01-27 10:02:30 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-27 06:20:04 +01:00
|
|
|
static int process_command(struct solos_card *card, int port, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct solos_param *prm;
|
|
|
|
unsigned long flags;
|
|
|
|
int cmdpid;
|
2015-12-04 08:43:19 +01:00
|
|
|
int found = 0, err;
|
2009-01-27 06:20:04 +01:00
|
|
|
|
|
|
|
if (skb->len < 7)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (skb->data[0] != 'L' || !isdigit(skb->data[1]) ||
|
|
|
|
!isdigit(skb->data[2]) || !isdigit(skb->data[3]) ||
|
|
|
|
!isdigit(skb->data[4]) || !isdigit(skb->data[5]) ||
|
|
|
|
skb->data[6] != '\n')
|
|
|
|
return 0;
|
|
|
|
|
2015-12-04 08:43:19 +01:00
|
|
|
err = kstrtoint(&skb->data[1], 10, &cmdpid);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-01-27 06:20:04 +01:00
|
|
|
|
|
|
|
spin_lock_irqsave(&card->param_queue_lock, flags);
|
|
|
|
list_for_each_entry(prm, &card->param_queue, list) {
|
|
|
|
if (prm->port == port && prm->pid == cmdpid) {
|
|
|
|
prm->response = skb;
|
|
|
|
skb_pull(skb, 7);
|
|
|
|
wake_up(&card->param_wq);
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&card->param_queue_lock, flags);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
static ssize_t console_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
|
|
|
|
struct solos_card *card = atmdev->dev_data;
|
|
|
|
struct sk_buff *skb;
|
2010-10-10 23:50:44 +02:00
|
|
|
unsigned int len;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
spin_lock(&card->cli_queue_lock);
|
|
|
|
skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]);
|
|
|
|
spin_unlock(&card->cli_queue_lock);
|
|
|
|
if(skb == NULL)
|
|
|
|
return sprintf(buf, "No data.\n");
|
|
|
|
|
2010-10-10 23:50:44 +02:00
|
|
|
len = skb->len;
|
|
|
|
memcpy(buf, skb->data, len);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
kfree_skb(skb);
|
2010-10-10 23:50:44 +02:00
|
|
|
return len;
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int send_command(struct solos_card *card, int dev, const char *buf, size_t size)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct pkt_hdr *header;
|
|
|
|
|
|
|
|
if (size > (BUF_SIZE - sizeof(*header))) {
|
|
|
|
dev_dbg(&card->dev->dev, "Command is too big. Dropping request\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
skb = alloc_skb(size + sizeof(*header), GFP_ATOMIC);
|
|
|
|
if (!skb) {
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate sk_buff in send_command()\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:21 +02:00
|
|
|
header = skb_put(skb, sizeof(*header));
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
header->size = cpu_to_le16(size);
|
|
|
|
header->vpi = cpu_to_le16(0);
|
|
|
|
header->vci = cpu_to_le16(0);
|
|
|
|
header->type = cpu_to_le16(PKT_COMMAND);
|
|
|
|
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:20 +02:00
|
|
|
skb_put_data(skb, buf, size);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
fpga_queue(card, dev, skb, NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t console_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
|
|
|
|
struct solos_card *card = atmdev->dev_data;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = send_command(card, SOLOS_CHAN(atmdev), buf, count);
|
|
|
|
|
|
|
|
return err?:count;
|
|
|
|
}
|
|
|
|
|
2012-12-19 12:01:18 +01:00
|
|
|
struct geos_gpio_attr {
|
|
|
|
struct device_attribute attr;
|
|
|
|
int offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SOLOS_GPIO_ATTR(_name, _mode, _show, _store, _offset) \
|
|
|
|
struct geos_gpio_attr gpio_attr_##_name = { \
|
|
|
|
.attr = __ATTR(_name, _mode, _show, _store), \
|
|
|
|
.offset = _offset }
|
|
|
|
|
|
|
|
static ssize_t geos_gpio_store(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2015-12-27 11:45:57 +01:00
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
2012-12-19 12:01:18 +01:00
|
|
|
struct geos_gpio_attr *gattr = container_of(attr, struct geos_gpio_attr, attr);
|
|
|
|
struct solos_card *card = pci_get_drvdata(pdev);
|
|
|
|
uint32_t data32;
|
|
|
|
|
|
|
|
if (count != 1 && (count != 2 || buf[1] != '\n'))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
spin_lock_irq(&card->param_queue_lock);
|
|
|
|
data32 = ioread32(card->config_regs + GPIO_STATUS);
|
|
|
|
if (buf[0] == '1') {
|
|
|
|
data32 |= 1 << gattr->offset;
|
|
|
|
iowrite32(data32, card->config_regs + GPIO_STATUS);
|
|
|
|
} else if (buf[0] == '0') {
|
|
|
|
data32 &= ~(1 << gattr->offset);
|
|
|
|
iowrite32(data32, card->config_regs + GPIO_STATUS);
|
|
|
|
} else {
|
|
|
|
count = -EINVAL;
|
|
|
|
}
|
2012-12-19 22:48:45 +01:00
|
|
|
spin_unlock_irq(&card->param_queue_lock);
|
2012-12-19 12:01:18 +01:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t geos_gpio_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
2015-12-27 11:45:57 +01:00
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
2012-12-19 12:01:18 +01:00
|
|
|
struct geos_gpio_attr *gattr = container_of(attr, struct geos_gpio_attr, attr);
|
|
|
|
struct solos_card *card = pci_get_drvdata(pdev);
|
|
|
|
uint32_t data32;
|
|
|
|
|
|
|
|
data32 = ioread32(card->config_regs + GPIO_STATUS);
|
|
|
|
data32 = (data32 >> gattr->offset) & 1;
|
|
|
|
|
|
|
|
return sprintf(buf, "%d\n", data32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t hardware_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
2015-12-27 11:45:57 +01:00
|
|
|
struct pci_dev *pdev = to_pci_dev(dev);
|
2012-12-19 12:01:18 +01:00
|
|
|
struct geos_gpio_attr *gattr = container_of(attr, struct geos_gpio_attr, attr);
|
|
|
|
struct solos_card *card = pci_get_drvdata(pdev);
|
|
|
|
uint32_t data32;
|
|
|
|
|
|
|
|
data32 = ioread32(card->config_regs + GPIO_STATUS);
|
|
|
|
switch (gattr->offset) {
|
|
|
|
case 0:
|
|
|
|
/* HardwareVersion */
|
|
|
|
data32 = data32 & 0x1F;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* HardwareVariant */
|
|
|
|
data32 = (data32 >> 5) & 0x0F;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return sprintf(buf, "%d\n", data32);
|
|
|
|
}
|
|
|
|
|
solos-pci: use permission-specific DEVICE_ATTR variants
Use DEVICE_ATTR_RW for read-write attributes. This simplifies the
source code, improves readbility, and reduces the chance of
inconsistencies.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@rw@
declarer name DEVICE_ATTR;
identifier x,x_show,x_store;
@@
DEVICE_ATTR(x, \(0644\|S_IRUGO|S_IWUSR\), x_show, x_store);
@script:ocaml@
x << rw.x;
x_show << rw.x_show;
x_store << rw.x_store;
@@
if not (x^"_show" = x_show && x^"_store" = x_store)
then Coccilib.include_match false
@@
declarer name DEVICE_ATTR_RW;
identifier rw.x,rw.x_show,rw.x_store;
@@
- DEVICE_ATTR(x, \(0644\|S_IRUGO|S_IWUSR\), x_show, x_store);
+ DEVICE_ATTR_RW(x);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-29 21:37:09 +02:00
|
|
|
static DEVICE_ATTR_RW(console);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-27 06:52:07 +01:00
|
|
|
|
|
|
|
#define SOLOS_ATTR_RO(x) static DEVICE_ATTR(x, 0444, solos_param_show, NULL);
|
|
|
|
#define SOLOS_ATTR_RW(x) static DEVICE_ATTR(x, 0644, solos_param_show, solos_param_store);
|
|
|
|
|
|
|
|
#include "solos-attrlist.c"
|
|
|
|
|
2012-12-19 12:01:18 +01:00
|
|
|
static SOLOS_GPIO_ATTR(GPIO1, 0644, geos_gpio_show, geos_gpio_store, 9);
|
|
|
|
static SOLOS_GPIO_ATTR(GPIO2, 0644, geos_gpio_show, geos_gpio_store, 10);
|
|
|
|
static SOLOS_GPIO_ATTR(GPIO3, 0644, geos_gpio_show, geos_gpio_store, 11);
|
|
|
|
static SOLOS_GPIO_ATTR(GPIO4, 0644, geos_gpio_show, geos_gpio_store, 12);
|
|
|
|
static SOLOS_GPIO_ATTR(GPIO5, 0644, geos_gpio_show, geos_gpio_store, 13);
|
|
|
|
static SOLOS_GPIO_ATTR(PushButton, 0444, geos_gpio_show, NULL, 14);
|
|
|
|
static SOLOS_GPIO_ATTR(HardwareVersion, 0444, hardware_show, NULL, 0);
|
|
|
|
static SOLOS_GPIO_ATTR(HardwareVariant, 0444, hardware_show, NULL, 1);
|
2009-01-27 06:52:07 +01:00
|
|
|
#undef SOLOS_ATTR_RO
|
|
|
|
#undef SOLOS_ATTR_RW
|
|
|
|
|
|
|
|
#define SOLOS_ATTR_RO(x) &dev_attr_##x.attr,
|
|
|
|
#define SOLOS_ATTR_RW(x) &dev_attr_##x.attr,
|
|
|
|
|
|
|
|
static struct attribute *solos_attrs[] = {
|
|
|
|
#include "solos-attrlist.c"
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-08-02 01:57:47 +02:00
|
|
|
static const struct attribute_group solos_attr_group = {
|
2009-01-27 06:52:07 +01:00
|
|
|
.attrs = solos_attrs,
|
|
|
|
.name = "parameters",
|
|
|
|
};
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2012-12-19 12:01:18 +01:00
|
|
|
static struct attribute *gpio_attrs[] = {
|
|
|
|
&gpio_attr_GPIO1.attr.attr,
|
|
|
|
&gpio_attr_GPIO2.attr.attr,
|
|
|
|
&gpio_attr_GPIO3.attr.attr,
|
|
|
|
&gpio_attr_GPIO4.attr.attr,
|
|
|
|
&gpio_attr_GPIO5.attr.attr,
|
|
|
|
&gpio_attr_PushButton.attr.attr,
|
|
|
|
&gpio_attr_HardwareVersion.attr.attr,
|
|
|
|
&gpio_attr_HardwareVariant.attr.attr,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2017-08-02 01:57:47 +02:00
|
|
|
static const struct attribute_group gpio_attr_group = {
|
2012-12-19 12:01:18 +01:00
|
|
|
.attrs = gpio_attrs,
|
|
|
|
.name = "gpio",
|
|
|
|
};
|
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
static int flash_upgrade(struct solos_card *card, int chip)
|
|
|
|
{
|
|
|
|
const struct firmware *fw;
|
|
|
|
const char *fw_name;
|
2009-01-21 21:45:49 +01:00
|
|
|
int blocksize = 0;
|
|
|
|
int numblocks = 0;
|
2009-01-27 04:16:12 +01:00
|
|
|
int offset;
|
|
|
|
|
2009-11-17 13:46:44 +01:00
|
|
|
switch (chip) {
|
|
|
|
case 0:
|
2009-01-27 04:16:12 +01:00
|
|
|
fw_name = "solos-FPGA.bin";
|
2012-12-19 12:01:20 +01:00
|
|
|
if (card->atmel_flash)
|
|
|
|
blocksize = ATMEL_FPGA_BLOCK;
|
|
|
|
else
|
|
|
|
blocksize = SPI_FLASH_BLOCK;
|
2009-11-17 13:46:44 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2009-01-27 04:16:12 +01:00
|
|
|
fw_name = "solos-Firmware.bin";
|
2012-12-19 12:01:20 +01:00
|
|
|
if (card->atmel_flash)
|
|
|
|
blocksize = ATMEL_SOLOS_BLOCK;
|
|
|
|
else
|
|
|
|
blocksize = SPI_FLASH_BLOCK;
|
2009-11-17 13:46:44 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2009-03-25 10:27:37 +01:00
|
|
|
if (card->fpga_version > LEGACY_BUFFERS){
|
|
|
|
fw_name = "solos-db-FPGA.bin";
|
2012-12-19 12:01:20 +01:00
|
|
|
if (card->atmel_flash)
|
|
|
|
blocksize = ATMEL_FPGA_BLOCK;
|
|
|
|
else
|
|
|
|
blocksize = SPI_FLASH_BLOCK;
|
2009-03-25 10:27:37 +01:00
|
|
|
} else {
|
2009-11-17 13:46:44 +01:00
|
|
|
dev_info(&card->dev->dev, "FPGA version doesn't support"
|
|
|
|
" daughter board upgrades\n");
|
2009-03-25 10:27:37 +01:00
|
|
|
return -EPERM;
|
|
|
|
}
|
2009-11-17 13:46:44 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2009-03-25 10:27:37 +01:00
|
|
|
if (card->fpga_version > LEGACY_BUFFERS){
|
|
|
|
fw_name = "solos-Firmware.bin";
|
2012-12-19 12:01:20 +01:00
|
|
|
if (card->atmel_flash)
|
|
|
|
blocksize = ATMEL_SOLOS_BLOCK;
|
|
|
|
else
|
|
|
|
blocksize = SPI_FLASH_BLOCK;
|
2009-03-25 10:27:37 +01:00
|
|
|
} else {
|
2009-11-17 13:46:44 +01:00
|
|
|
dev_info(&card->dev->dev, "FPGA version doesn't support"
|
|
|
|
" daughter board upgrades\n");
|
|
|
|
return -EPERM;
|
2009-03-25 10:27:37 +01:00
|
|
|
}
|
2009-11-17 13:46:44 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -ENODEV;
|
2009-03-25 10:27:37 +01:00
|
|
|
}
|
2009-01-27 04:16:12 +01:00
|
|
|
|
|
|
|
if (request_firmware(&fw, fw_name, &card->dev->dev))
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
dev_info(&card->dev->dev, "Flash upgrade starting\n");
|
|
|
|
|
2012-12-19 12:01:20 +01:00
|
|
|
/* New FPGAs require driver version before permitting flash upgrades */
|
|
|
|
iowrite32(DRIVER_VERSION, card->config_regs + DRIVER_VER);
|
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
numblocks = fw->size / blocksize;
|
|
|
|
dev_info(&card->dev->dev, "Firmware size: %zd\n", fw->size);
|
2009-01-21 21:45:49 +01:00
|
|
|
dev_info(&card->dev->dev, "Number of blocks: %d\n", numblocks);
|
|
|
|
|
|
|
|
dev_info(&card->dev->dev, "Changing FPGA to Update mode\n");
|
|
|
|
iowrite32(1, card->config_regs + FPGA_MODE);
|
2011-04-17 09:11:25 +02:00
|
|
|
(void) ioread32(card->config_regs + FPGA_MODE);
|
2009-01-21 21:45:49 +01:00
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
/* Set mode to Chip Erase */
|
2009-03-25 10:27:37 +01:00
|
|
|
if(chip == 0 || chip == 2)
|
|
|
|
dev_info(&card->dev->dev, "Set FPGA Flash mode to FPGA Chip Erase\n");
|
|
|
|
if(chip == 1 || chip == 3)
|
|
|
|
dev_info(&card->dev->dev, "Set FPGA Flash mode to Solos Chip Erase\n");
|
2009-01-27 04:16:12 +01:00
|
|
|
iowrite32((chip * 2), card->config_regs + FLASH_MODE);
|
2009-01-21 21:45:49 +01:00
|
|
|
|
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
iowrite32(1, card->config_regs + WRITE_FLASH);
|
|
|
|
wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY));
|
|
|
|
|
|
|
|
for (offset = 0; offset < fw->size; offset += blocksize) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Clear write flag */
|
2009-01-21 21:45:49 +01:00
|
|
|
iowrite32(0, card->config_regs + WRITE_FLASH);
|
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
/* Set mode to Block Write */
|
|
|
|
/* dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n"); */
|
|
|
|
iowrite32(((chip * 2) + 1), card->config_regs + FLASH_MODE);
|
|
|
|
|
2012-12-19 12:01:20 +01:00
|
|
|
/* Copy block to buffer, swapping each 16 bits for Atmel flash */
|
2009-01-27 04:16:12 +01:00
|
|
|
for(i = 0; i < blocksize; i += 4) {
|
2012-12-19 12:01:20 +01:00
|
|
|
uint32_t word;
|
|
|
|
if (card->atmel_flash)
|
|
|
|
word = swahb32p((uint32_t *)(fw->data + offset + i));
|
|
|
|
else
|
|
|
|
word = *(uint32_t *)(fw->data + offset + i);
|
2009-03-25 10:27:37 +01:00
|
|
|
if(card->fpga_version > LEGACY_BUFFERS)
|
|
|
|
iowrite32(word, FLASH_BUF + i);
|
|
|
|
else
|
|
|
|
iowrite32(word, RX_BUF(card, 3) + i);
|
2009-01-21 21:45:49 +01:00
|
|
|
}
|
2009-01-27 04:16:12 +01:00
|
|
|
|
|
|
|
/* Specify block number and then trigger flash write */
|
|
|
|
iowrite32(offset / blocksize, card->config_regs + FLASH_BLOCK);
|
|
|
|
iowrite32(1, card->config_regs + WRITE_FLASH);
|
|
|
|
wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY));
|
2009-01-21 21:45:49 +01:00
|
|
|
}
|
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
release_firmware(fw);
|
|
|
|
iowrite32(0, card->config_regs + WRITE_FLASH);
|
|
|
|
iowrite32(0, card->config_regs + FPGA_MODE);
|
|
|
|
iowrite32(0, card->config_regs + FLASH_MODE);
|
|
|
|
dev_info(&card->dev->dev, "Returning FPGA to Data mode\n");
|
|
|
|
return 0;
|
2009-01-21 21:45:49 +01:00
|
|
|
}
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
static irqreturn_t solos_irq(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct solos_card *card = dev_id;
|
|
|
|
int handled = 1;
|
|
|
|
|
|
|
|
iowrite32(0, card->config_regs + IRQ_CLEAR);
|
|
|
|
|
2009-01-29 04:08:27 +01:00
|
|
|
/* If we're up and running, just kick the tasklet to process TX/RX */
|
2009-01-27 04:16:12 +01:00
|
|
|
if (card->atmdev[0])
|
2008-12-23 05:09:02 +01:00
|
|
|
tasklet_schedule(&card->tlet);
|
2009-01-27 04:16:12 +01:00
|
|
|
else
|
|
|
|
wake_up(&card->fw_wq);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
2014-02-19 02:49:12 +01:00
|
|
|
static void solos_bh(unsigned long card_arg)
|
2008-12-23 05:09:02 +01:00
|
|
|
{
|
|
|
|
struct solos_card *card = (void *)card_arg;
|
|
|
|
uint32_t card_flags;
|
|
|
|
uint32_t rx_done = 0;
|
2009-01-29 04:08:27 +01:00
|
|
|
int port;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-29 04:08:27 +01:00
|
|
|
/*
|
|
|
|
* Since fpga_tx() is going to need to read the flags under its lock,
|
|
|
|
* it can return them to us so that we don't have to hit PCI MMIO
|
|
|
|
* again for the same information
|
|
|
|
*/
|
|
|
|
card_flags = fpga_tx(card);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
for (port = 0; port < card->nr_ports; port++) {
|
|
|
|
if (card_flags & (0x10 << port)) {
|
2009-01-28 06:46:56 +01:00
|
|
|
struct pkt_hdr _hdr, *header;
|
2008-12-23 05:09:02 +01:00
|
|
|
struct sk_buff *skb;
|
|
|
|
struct atm_vcc *vcc;
|
|
|
|
int size;
|
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
if (card->using_dma) {
|
|
|
|
skb = card->rx_skb[port];
|
2009-01-29 00:51:11 +01:00
|
|
|
card->rx_skb[port] = NULL;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2015-01-16 14:57:21 +01:00
|
|
|
dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr,
|
|
|
|
RX_DMA_SIZE, DMA_FROM_DEVICE);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
header = (void *)skb->data;
|
|
|
|
size = le16_to_cpu(header->size);
|
|
|
|
skb_put(skb, size + sizeof(*header));
|
|
|
|
skb_pull(skb, sizeof(*header));
|
|
|
|
} else {
|
|
|
|
header = &_hdr;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
rx_done |= 0x10 << port;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
memcpy_fromio(header, RX_BUF(card, port), sizeof(*header));
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
size = le16_to_cpu(header->size);
|
2009-03-25 10:33:42 +01:00
|
|
|
if (size > (card->buffer_size - sizeof(*header))){
|
|
|
|
dev_warn(&card->dev->dev, "Invalid buffer size\n");
|
|
|
|
continue;
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2015-09-16 13:35:00 +02:00
|
|
|
/* Use netdev_alloc_skb() because it adds NET_SKB_PAD of
|
|
|
|
* headroom, and ensures we can route packets back out an
|
|
|
|
* Ethernet interface (for example) without having to
|
|
|
|
* reallocate. Adding NET_IP_ALIGN also ensures that both
|
|
|
|
* PPPoATM and PPPoEoBR2684 packets end up aligned. */
|
|
|
|
skb = netdev_alloc_skb_ip_align(NULL, size + 1);
|
2009-01-28 06:46:56 +01:00
|
|
|
if (!skb) {
|
|
|
|
if (net_ratelimit())
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
|
|
|
|
continue;
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
memcpy_fromio(skb_put(skb, size),
|
|
|
|
RX_BUF(card, port) + sizeof(*header),
|
|
|
|
size);
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
if (atmdebug) {
|
2011-03-30 14:59:26 +02:00
|
|
|
dev_info(&card->dev->dev, "Received: port %d\n", port);
|
2008-12-23 05:09:02 +01:00
|
|
|
dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n",
|
2009-01-28 06:46:56 +01:00
|
|
|
size, le16_to_cpu(header->vpi),
|
|
|
|
le16_to_cpu(header->vci));
|
2008-12-23 05:09:02 +01:00
|
|
|
print_buffer(skb);
|
|
|
|
}
|
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
switch (le16_to_cpu(header->type)) {
|
2008-12-23 05:09:02 +01:00
|
|
|
case PKT_DATA:
|
2009-01-28 06:46:56 +01:00
|
|
|
vcc = find_vcc(card->atmdev[port], le16_to_cpu(header->vpi),
|
|
|
|
le16_to_cpu(header->vci));
|
2008-12-23 05:09:02 +01:00
|
|
|
if (!vcc) {
|
|
|
|
if (net_ratelimit())
|
2011-03-30 15:22:45 +02:00
|
|
|
dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n",
|
|
|
|
le16_to_cpu(header->vpi), le16_to_cpu(header->vci),
|
2008-12-23 05:09:02 +01:00
|
|
|
port);
|
2012-11-27 07:34:09 +01:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
break;
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
atm_charge(vcc, skb->truesize);
|
|
|
|
vcc->push(vcc, skb);
|
|
|
|
atomic_inc(&vcc->stats->rx);
|
|
|
|
break;
|
|
|
|
|
2009-01-27 10:02:30 +01:00
|
|
|
case PKT_STATUS:
|
2009-01-30 04:23:52 +01:00
|
|
|
if (process_status(card, port, skb) &&
|
|
|
|
net_ratelimit()) {
|
|
|
|
dev_warn(&card->dev->dev, "Bad status packet of %d bytes on port %d:\n", skb->len, port);
|
|
|
|
print_buffer(skb);
|
|
|
|
}
|
2009-01-29 00:51:11 +01:00
|
|
|
dev_kfree_skb_any(skb);
|
2009-01-27 10:02:30 +01:00
|
|
|
break;
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
case PKT_COMMAND:
|
|
|
|
default: /* FIXME: Not really, surely? */
|
2009-01-27 06:20:04 +01:00
|
|
|
if (process_command(card, port, skb))
|
|
|
|
break;
|
2008-12-23 05:09:02 +01:00
|
|
|
spin_lock(&card->cli_queue_lock);
|
|
|
|
if (skb_queue_len(&card->cli_queue[port]) > 10) {
|
|
|
|
if (net_ratelimit())
|
|
|
|
dev_warn(&card->dev->dev, "Dropping console response on port %d\n",
|
|
|
|
port);
|
2009-01-29 00:51:11 +01:00
|
|
|
dev_kfree_skb_any(skb);
|
2008-12-23 05:09:02 +01:00
|
|
|
} else
|
|
|
|
skb_queue_tail(&card->cli_queue[port], skb);
|
|
|
|
spin_unlock(&card->cli_queue_lock);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-01-29 00:51:11 +01:00
|
|
|
/* Allocate RX skbs for any ports which need them */
|
|
|
|
if (card->using_dma && card->atmdev[port] &&
|
|
|
|
!card->rx_skb[port]) {
|
2015-09-16 13:35:00 +02:00
|
|
|
/* Unlike the MMIO case (qv) we can't add NET_IP_ALIGN
|
|
|
|
* here; the FPGA can only DMA to addresses which are
|
|
|
|
* aligned to 4 bytes. */
|
|
|
|
struct sk_buff *skb = dev_alloc_skb(RX_DMA_SIZE);
|
2009-01-29 00:51:11 +01:00
|
|
|
if (skb) {
|
|
|
|
SKB_CB(skb)->dma_addr =
|
2015-01-16 14:57:21 +01:00
|
|
|
dma_map_single(&card->dev->dev, skb->data,
|
|
|
|
RX_DMA_SIZE, DMA_FROM_DEVICE);
|
2009-01-29 00:51:11 +01:00
|
|
|
iowrite32(SKB_CB(skb)->dma_addr,
|
|
|
|
card->config_regs + RX_DMA_ADDR(port));
|
|
|
|
card->rx_skb[port] = skb;
|
|
|
|
} else {
|
|
|
|
if (net_ratelimit())
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate RX skb");
|
|
|
|
|
|
|
|
/* We'll have to try again later */
|
|
|
|
tasklet_schedule(&card->tlet);
|
|
|
|
}
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
if (rx_done)
|
|
|
|
iowrite32(rx_done, card->config_regs + FLAGS_ADDR);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct atm_vcc *find_vcc(struct atm_dev *dev, short vpi, int vci)
|
|
|
|
{
|
|
|
|
struct hlist_head *head;
|
|
|
|
struct atm_vcc *vcc = NULL;
|
|
|
|
struct sock *s;
|
|
|
|
|
|
|
|
read_lock(&vcc_sklist_lock);
|
|
|
|
head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)];
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 02:06:00 +01:00
|
|
|
sk_for_each(s, head) {
|
2008-12-23 05:09:02 +01:00
|
|
|
vcc = atm_sk(s);
|
|
|
|
if (vcc->dev == dev && vcc->vci == vci &&
|
2010-08-08 08:02:59 +02:00
|
|
|
vcc->vpi == vpi && vcc->qos.rxtp.traffic_class != ATM_NONE &&
|
|
|
|
test_bit(ATM_VF_READY, &vcc->flags))
|
2008-12-23 05:09:02 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
vcc = NULL;
|
|
|
|
out:
|
|
|
|
read_unlock(&vcc_sklist_lock);
|
|
|
|
return vcc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int popen(struct atm_vcc *vcc)
|
|
|
|
{
|
|
|
|
struct solos_card *card = vcc->dev->dev_data;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct pkt_hdr *header;
|
|
|
|
|
2009-01-27 11:50:36 +01:00
|
|
|
if (vcc->qos.aal != ATM_AAL5) {
|
|
|
|
dev_warn(&card->dev->dev, "Unsupported ATM type %d\n",
|
|
|
|
vcc->qos.aal);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2012-11-30 00:27:20 +01:00
|
|
|
skb = alloc_skb(sizeof(*header), GFP_KERNEL);
|
2011-02-13 11:49:32 +01:00
|
|
|
if (!skb) {
|
|
|
|
if (net_ratelimit())
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n");
|
2008-12-23 05:09:02 +01:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:21 +02:00
|
|
|
header = skb_put(skb, sizeof(*header));
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-27 00:18:51 +01:00
|
|
|
header->size = cpu_to_le16(0);
|
2008-12-23 05:09:02 +01:00
|
|
|
header->vpi = cpu_to_le16(vcc->vpi);
|
|
|
|
header->vci = cpu_to_le16(vcc->vci);
|
|
|
|
header->type = cpu_to_le16(PKT_POPEN);
|
|
|
|
|
|
|
|
fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL);
|
|
|
|
|
2009-01-29 04:37:20 +01:00
|
|
|
set_bit(ATM_VF_ADDR, &vcc->flags);
|
2008-12-23 05:09:02 +01:00
|
|
|
set_bit(ATM_VF_READY, &vcc->flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pclose(struct atm_vcc *vcc)
|
|
|
|
{
|
|
|
|
struct solos_card *card = vcc->dev->dev_data;
|
2012-11-28 00:49:24 +01:00
|
|
|
unsigned char port = SOLOS_CHAN(vcc->dev);
|
2012-11-30 00:15:30 +01:00
|
|
|
struct sk_buff *skb, *tmpskb;
|
2008-12-23 05:09:02 +01:00
|
|
|
struct pkt_hdr *header;
|
|
|
|
|
2012-11-30 00:15:30 +01:00
|
|
|
/* Remove any yet-to-be-transmitted packets from the pending queue */
|
|
|
|
spin_lock(&card->tx_queue_lock);
|
|
|
|
skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) {
|
|
|
|
if (SKB_CB(skb)->vcc == vcc) {
|
|
|
|
skb_unlink(skb, &card->tx_queue[port]);
|
|
|
|
solos_pop(vcc, skb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&card->tx_queue_lock);
|
|
|
|
|
2012-11-30 00:27:20 +01:00
|
|
|
skb = alloc_skb(sizeof(*header), GFP_KERNEL);
|
2008-12-23 05:09:02 +01:00
|
|
|
if (!skb) {
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n");
|
|
|
|
return;
|
|
|
|
}
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:21 +02:00
|
|
|
header = skb_put(skb, sizeof(*header));
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-27 00:18:51 +01:00
|
|
|
header->size = cpu_to_le16(0);
|
2008-12-23 05:09:02 +01:00
|
|
|
header->vpi = cpu_to_le16(vcc->vpi);
|
|
|
|
header->vci = cpu_to_le16(vcc->vci);
|
|
|
|
header->type = cpu_to_le16(PKT_PCLOSE);
|
|
|
|
|
2012-11-28 00:49:24 +01:00
|
|
|
skb_get(skb);
|
|
|
|
fpga_queue(card, port, skb, NULL);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2012-11-28 00:49:24 +01:00
|
|
|
if (!wait_event_timeout(card->param_wq, !skb_shared(skb), 5 * HZ))
|
|
|
|
dev_warn(&card->dev->dev,
|
|
|
|
"Timeout waiting for VCC close on port %d\n", port);
|
|
|
|
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
2010-08-08 08:02:59 +02:00
|
|
|
/* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the
|
|
|
|
tasklet has finished processing any incoming packets (and, more to
|
|
|
|
the point, using the vcc pointer). */
|
|
|
|
tasklet_unlock_wait(&card->tlet);
|
2012-11-30 00:15:30 +01:00
|
|
|
|
|
|
|
clear_bit(ATM_VF_ADDR, &vcc->flags);
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int print_buffer(struct sk_buff *buf)
|
|
|
|
{
|
|
|
|
int len,i;
|
|
|
|
char msg[500];
|
|
|
|
char item[10];
|
|
|
|
|
|
|
|
len = buf->len;
|
|
|
|
for (i = 0; i < len; i++){
|
|
|
|
if(i % 8 == 0)
|
|
|
|
sprintf(msg, "%02X: ", i);
|
|
|
|
|
|
|
|
sprintf(item,"%02X ",*(buf->data + i));
|
|
|
|
strcat(msg, item);
|
|
|
|
if(i % 8 == 7) {
|
|
|
|
sprintf(item, "\n");
|
|
|
|
strcat(msg, item);
|
|
|
|
printk(KERN_DEBUG "%s", msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i % 8 != 0) {
|
|
|
|
sprintf(item, "\n");
|
|
|
|
strcat(msg, item);
|
|
|
|
printk(KERN_DEBUG "%s", msg);
|
|
|
|
}
|
|
|
|
printk(KERN_DEBUG "\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb,
|
|
|
|
struct atm_vcc *vcc)
|
|
|
|
{
|
|
|
|
int old_len;
|
2009-01-29 01:10:58 +01:00
|
|
|
unsigned long flags;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-28 06:46:56 +01:00
|
|
|
SKB_CB(skb)->vcc = vcc;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-29 01:10:58 +01:00
|
|
|
spin_lock_irqsave(&card->tx_queue_lock, flags);
|
2008-12-23 05:09:02 +01:00
|
|
|
old_len = skb_queue_len(&card->tx_queue[port]);
|
|
|
|
skb_queue_tail(&card->tx_queue[port], skb);
|
2009-01-29 04:08:27 +01:00
|
|
|
if (!old_len)
|
2009-01-29 01:10:58 +01:00
|
|
|
card->tx_mask |= (1 << port);
|
|
|
|
spin_unlock_irqrestore(&card->tx_queue_lock, flags);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-29 01:10:58 +01:00
|
|
|
/* Theoretically we could just schedule the tasklet here, but
|
|
|
|
that introduces latency we don't want -- it's noticeable */
|
2008-12-23 05:09:02 +01:00
|
|
|
if (!old_len)
|
|
|
|
fpga_tx(card);
|
|
|
|
}
|
|
|
|
|
2009-01-29 04:08:27 +01:00
|
|
|
static uint32_t fpga_tx(struct solos_card *card)
|
2008-12-23 05:09:02 +01:00
|
|
|
{
|
2009-01-29 04:08:27 +01:00
|
|
|
uint32_t tx_pending, card_flags;
|
2008-12-23 05:09:02 +01:00
|
|
|
uint32_t tx_started = 0;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct atm_vcc *vcc;
|
|
|
|
unsigned char port;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&card->tx_lock, flags);
|
2009-01-29 04:08:27 +01:00
|
|
|
|
|
|
|
card_flags = ioread32(card->config_regs + FLAGS_ADDR);
|
|
|
|
/*
|
|
|
|
* The queue lock is required for _writing_ to tx_mask, but we're
|
|
|
|
* OK to read it here without locking. The only potential update
|
|
|
|
* that we could race with is in fpga_queue() where it sets a bit
|
|
|
|
* for a new port... but it's going to call this function again if
|
|
|
|
* it's doing that, anyway.
|
|
|
|
*/
|
|
|
|
tx_pending = card->tx_mask & ~card_flags;
|
|
|
|
|
|
|
|
for (port = 0; tx_pending; tx_pending >>= 1, port++) {
|
|
|
|
if (tx_pending & 1) {
|
2009-01-29 00:51:11 +01:00
|
|
|
struct sk_buff *oldskb = card->tx_skb[port];
|
2012-12-11 15:57:14 +01:00
|
|
|
if (oldskb) {
|
2015-01-16 14:57:21 +01:00
|
|
|
dma_unmap_single(&card->dev->dev, SKB_CB(oldskb)->dma_addr,
|
|
|
|
oldskb->len, DMA_TO_DEVICE);
|
2012-12-11 15:57:14 +01:00
|
|
|
card->tx_skb[port] = NULL;
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
spin_lock(&card->tx_queue_lock);
|
|
|
|
skb = skb_dequeue(&card->tx_queue[port]);
|
2009-01-29 01:10:58 +01:00
|
|
|
if (!skb)
|
|
|
|
card->tx_mask &= ~(1 << port);
|
2008-12-23 05:09:02 +01:00
|
|
|
spin_unlock(&card->tx_queue_lock);
|
|
|
|
|
2009-01-29 00:51:11 +01:00
|
|
|
if (skb && !card->using_dma) {
|
|
|
|
memcpy_toio(TX_BUF(card, port), skb->data, skb->len);
|
2009-01-29 04:37:20 +01:00
|
|
|
tx_started |= 1 << port;
|
2009-01-29 00:51:11 +01:00
|
|
|
oldskb = skb; /* We're done with this skb already */
|
|
|
|
} else if (skb && card->using_dma) {
|
2012-12-19 12:01:21 +01:00
|
|
|
unsigned char *data = skb->data;
|
|
|
|
if ((unsigned long)data & card->dma_alignment) {
|
|
|
|
data = card->dma_bounce + (BUF_SIZE * port);
|
|
|
|
memcpy(data, skb->data, skb->len);
|
|
|
|
}
|
2015-01-16 14:57:21 +01:00
|
|
|
SKB_CB(skb)->dma_addr = dma_map_single(&card->dev->dev, data,
|
|
|
|
skb->len, DMA_TO_DEVICE);
|
2012-05-24 06:58:27 +02:00
|
|
|
card->tx_skb[port] = skb;
|
2009-01-29 00:51:11 +01:00
|
|
|
iowrite32(SKB_CB(skb)->dma_addr,
|
|
|
|
card->config_regs + TX_DMA_ADDR(port));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!oldskb)
|
2008-12-23 05:09:02 +01:00
|
|
|
continue;
|
|
|
|
|
2009-01-29 00:51:11 +01:00
|
|
|
/* Clean up and free oldskb now it's gone */
|
2008-12-23 05:09:02 +01:00
|
|
|
if (atmdebug) {
|
2011-03-30 14:59:26 +02:00
|
|
|
struct pkt_hdr *header = (void *)oldskb->data;
|
|
|
|
int size = le16_to_cpu(header->size);
|
|
|
|
|
|
|
|
skb_pull(oldskb, sizeof(*header));
|
2008-12-23 05:09:02 +01:00
|
|
|
dev_info(&card->dev->dev, "Transmitted: port %d\n",
|
|
|
|
port);
|
2011-03-30 14:59:26 +02:00
|
|
|
dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n",
|
|
|
|
size, le16_to_cpu(header->vpi),
|
|
|
|
le16_to_cpu(header->vci));
|
2009-01-29 00:51:11 +01:00
|
|
|
print_buffer(oldskb);
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
|
2009-01-29 00:51:11 +01:00
|
|
|
vcc = SKB_CB(oldskb)->vcc;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
if (vcc) {
|
|
|
|
atomic_inc(&vcc->stats->tx);
|
2009-01-29 00:51:11 +01:00
|
|
|
solos_pop(vcc, oldskb);
|
2012-11-28 00:49:24 +01:00
|
|
|
} else {
|
2009-01-29 00:51:11 +01:00
|
|
|
dev_kfree_skb_irq(oldskb);
|
2012-11-28 00:49:24 +01:00
|
|
|
wake_up(&card->param_wq);
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
}
|
2009-01-29 04:37:20 +01:00
|
|
|
/* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */
|
2008-12-23 05:09:02 +01:00
|
|
|
if (tx_started)
|
|
|
|
iowrite32(tx_started, card->config_regs + FLAGS_ADDR);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&card->tx_lock, flags);
|
2009-01-29 04:08:27 +01:00
|
|
|
return card_flags;
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int psend(struct atm_vcc *vcc, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct solos_card *card = vcc->dev->dev_data;
|
|
|
|
struct pkt_hdr *header;
|
2009-01-27 00:18:51 +01:00
|
|
|
int pktlen;
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-27 00:18:51 +01:00
|
|
|
pktlen = skb->len;
|
|
|
|
if (pktlen > (BUF_SIZE - sizeof(*header))) {
|
2008-12-23 05:09:02 +01:00
|
|
|
dev_warn(&card->dev->dev, "Length of PDU is too large. Dropping PDU.\n");
|
|
|
|
solos_pop(vcc, skb);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!skb_clone_writable(skb, sizeof(*header))) {
|
|
|
|
int expand_by = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (skb_headroom(skb) < sizeof(*header))
|
|
|
|
expand_by = sizeof(*header) - skb_headroom(skb);
|
|
|
|
|
|
|
|
ret = pskb_expand_head(skb, expand_by, 0, GFP_ATOMIC);
|
|
|
|
if (ret) {
|
2009-01-19 22:19:29 +01:00
|
|
|
dev_warn(&card->dev->dev, "pskb_expand_head failed.\n");
|
2008-12-23 05:09:02 +01:00
|
|
|
solos_pop(vcc, skb);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
networking: make skb_push & __skb_push return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions return void * and remove all the casts across
the tree, adding a (u8 *) cast only where the unsigned char pointer
was used directly, all done with the following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
@@
expression SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- fn(SKB, LEN)[0]
+ *(u8 *)fn(SKB, LEN)
Note that the last part there converts from push(...)[0] to the
more idiomatic *(u8 *)push(...).
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:23 +02:00
|
|
|
header = skb_push(skb, sizeof(*header));
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-27 00:18:51 +01:00
|
|
|
/* This does _not_ include the size of the header */
|
|
|
|
header->size = cpu_to_le16(pktlen);
|
2008-12-23 05:09:02 +01:00
|
|
|
header->vpi = cpu_to_le16(vcc->vpi);
|
|
|
|
header->vci = cpu_to_le16(vcc->vci);
|
|
|
|
header->type = cpu_to_le16(PKT_DATA);
|
|
|
|
|
|
|
|
fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, vcc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-09 11:19:15 +02:00
|
|
|
static const struct atmdev_ops fpga_ops = {
|
2008-12-23 05:09:02 +01:00
|
|
|
.open = popen,
|
|
|
|
.close = pclose,
|
|
|
|
.ioctl = NULL,
|
|
|
|
.getsockopt = NULL,
|
|
|
|
.setsockopt = NULL,
|
|
|
|
.send = psend,
|
|
|
|
.send_oam = NULL,
|
|
|
|
.phy_put = NULL,
|
|
|
|
.phy_get = NULL,
|
|
|
|
.change_qos = NULL,
|
|
|
|
.proc_read = NULL,
|
|
|
|
.owner = THIS_MODULE
|
|
|
|
};
|
|
|
|
|
|
|
|
static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
|
|
|
{
|
2009-01-30 04:26:37 +01:00
|
|
|
int err;
|
2008-12-23 05:09:02 +01:00
|
|
|
uint16_t fpga_ver;
|
|
|
|
uint8_t major_ver, minor_ver;
|
|
|
|
uint32_t data32;
|
|
|
|
struct solos_card *card;
|
|
|
|
|
|
|
|
card = kzalloc(sizeof(*card), GFP_KERNEL);
|
|
|
|
if (!card)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
card->dev = dev;
|
2009-01-27 04:16:12 +01:00
|
|
|
init_waitqueue_head(&card->fw_wq);
|
2009-01-27 06:20:04 +01:00
|
|
|
init_waitqueue_head(&card->param_wq);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
err = pci_enable_device(dev);
|
|
|
|
if (err) {
|
|
|
|
dev_warn(&dev->dev, "Failed to enable PCI device\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2015-01-16 14:57:21 +01:00
|
|
|
err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
|
2009-01-28 06:46:56 +01:00
|
|
|
if (err) {
|
|
|
|
dev_warn(&dev->dev, "Failed to set 32-bit DMA mask\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
err = pci_request_regions(dev, "solos");
|
|
|
|
if (err) {
|
|
|
|
dev_warn(&dev->dev, "Failed to request regions\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
card->config_regs = pci_iomap(dev, 0, CONFIG_RAM_SIZE);
|
|
|
|
if (!card->config_regs) {
|
|
|
|
dev_warn(&dev->dev, "Failed to ioremap config registers\n");
|
2014-11-22 15:39:17 +01:00
|
|
|
err = -ENOMEM;
|
2008-12-23 05:09:02 +01:00
|
|
|
goto out_release_regions;
|
|
|
|
}
|
|
|
|
card->buffers = pci_iomap(dev, 1, DATA_RAM_SIZE);
|
|
|
|
if (!card->buffers) {
|
|
|
|
dev_warn(&dev->dev, "Failed to ioremap data buffers\n");
|
2014-11-22 15:39:17 +01:00
|
|
|
err = -ENOMEM;
|
2008-12-23 05:09:02 +01:00
|
|
|
goto out_unmap_config;
|
|
|
|
}
|
|
|
|
|
2009-01-30 04:23:22 +01:00
|
|
|
if (reset) {
|
|
|
|
iowrite32(1, card->config_regs + FPGA_MODE);
|
2017-06-15 21:56:21 +02:00
|
|
|
ioread32(card->config_regs + FPGA_MODE);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-01-30 04:23:22 +01:00
|
|
|
iowrite32(0, card->config_regs + FPGA_MODE);
|
2017-06-15 21:56:21 +02:00
|
|
|
ioread32(card->config_regs + FPGA_MODE);
|
2009-01-30 04:23:22 +01:00
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
data32 = ioread32(card->config_regs + FPGA_VER);
|
|
|
|
fpga_ver = (data32 & 0x0000FFFF);
|
|
|
|
major_ver = ((data32 & 0xFF000000) >> 24);
|
|
|
|
minor_ver = ((data32 & 0x00FF0000) >> 16);
|
2009-03-25 10:27:37 +01:00
|
|
|
card->fpga_version = FPGA_VERSION(major_ver,minor_ver);
|
|
|
|
if (card->fpga_version > LEGACY_BUFFERS)
|
|
|
|
card->buffer_size = BUF_SIZE;
|
|
|
|
else
|
|
|
|
card->buffer_size = OLD_BUF_SIZE;
|
2008-12-23 05:09:02 +01:00
|
|
|
dev_info(&dev->dev, "Solos FPGA Version %d.%02d svn-%d\n",
|
|
|
|
major_ver, minor_ver, fpga_ver);
|
|
|
|
|
2010-11-01 11:35:28 +01:00
|
|
|
if (fpga_ver < 37 && (fpga_upgrade || firmware_upgrade ||
|
|
|
|
db_fpga_upgrade || db_firmware_upgrade)) {
|
|
|
|
dev_warn(&dev->dev,
|
|
|
|
"FPGA too old; cannot upgrade flash. Use JTAG.\n");
|
|
|
|
fpga_upgrade = firmware_upgrade = 0;
|
|
|
|
db_fpga_upgrade = db_firmware_upgrade = 0;
|
|
|
|
}
|
|
|
|
|
2012-12-19 12:01:20 +01:00
|
|
|
/* Stopped using Atmel flash after 0.03-38 */
|
|
|
|
if (fpga_ver < 39)
|
|
|
|
card->atmel_flash = 1;
|
|
|
|
else
|
|
|
|
card->atmel_flash = 0;
|
|
|
|
|
2012-12-19 12:01:21 +01:00
|
|
|
data32 = ioread32(card->config_regs + PORTS);
|
|
|
|
card->nr_ports = (data32 & 0x000000FF);
|
|
|
|
|
2012-05-24 06:58:27 +02:00
|
|
|
if (card->fpga_version >= DMA_SUPPORTED) {
|
|
|
|
pci_set_master(dev);
|
2009-01-28 06:46:56 +01:00
|
|
|
card->using_dma = 1;
|
2012-12-19 12:01:21 +01:00
|
|
|
if (1) { /* All known FPGA versions so far */
|
|
|
|
card->dma_alignment = 3;
|
treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:
kmalloc(a * b, gfp)
with:
kmalloc_array(a * b, gfp)
as well as handling cases of:
kmalloc(a * b * c, gfp)
with:
kmalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kmalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kmalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 22:55:00 +02:00
|
|
|
card->dma_bounce = kmalloc_array(card->nr_ports,
|
|
|
|
BUF_SIZE, GFP_KERNEL);
|
2012-12-19 12:01:21 +01:00
|
|
|
if (!card->dma_bounce) {
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
|
2014-08-07 14:49:07 +02:00
|
|
|
err = -ENOMEM;
|
2012-12-19 12:01:21 +01:00
|
|
|
/* Fallback to MMIO doesn't work */
|
|
|
|
goto out_unmap_both;
|
|
|
|
}
|
|
|
|
}
|
2009-03-25 10:27:37 +01:00
|
|
|
} else {
|
|
|
|
card->using_dma = 0;
|
2009-01-30 04:27:26 +01:00
|
|
|
/* Set RX empty flag for all ports */
|
|
|
|
iowrite32(0xF0, card->config_regs + FLAGS_ADDR);
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
pci_set_drvdata(dev, card);
|
2009-01-27 04:16:12 +01:00
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
tasklet_init(&card->tlet, solos_bh, (unsigned long)card);
|
|
|
|
spin_lock_init(&card->tx_lock);
|
|
|
|
spin_lock_init(&card->tx_queue_lock);
|
|
|
|
spin_lock_init(&card->cli_queue_lock);
|
2009-01-27 06:20:04 +01:00
|
|
|
spin_lock_init(&card->param_queue_lock);
|
|
|
|
INIT_LIST_HEAD(&card->param_queue);
|
2009-01-27 04:16:12 +01:00
|
|
|
|
2009-01-29 01:29:12 +01:00
|
|
|
err = request_irq(dev->irq, solos_irq, IRQF_SHARED,
|
2008-12-23 05:09:02 +01:00
|
|
|
"solos-pci", card);
|
2009-01-27 04:16:12 +01:00
|
|
|
if (err) {
|
2008-12-23 05:09:02 +01:00
|
|
|
dev_dbg(&card->dev->dev, "Failed to request interrupt IRQ: %d\n", dev->irq);
|
2009-01-27 04:16:12 +01:00
|
|
|
goto out_unmap_both;
|
|
|
|
}
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
iowrite32(1, card->config_regs + IRQ_EN_ADDR);
|
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
if (fpga_upgrade)
|
|
|
|
flash_upgrade(card, 0);
|
|
|
|
|
|
|
|
if (firmware_upgrade)
|
|
|
|
flash_upgrade(card, 1);
|
|
|
|
|
2009-03-25 10:27:37 +01:00
|
|
|
if (db_fpga_upgrade)
|
|
|
|
flash_upgrade(card, 2);
|
|
|
|
|
|
|
|
if (db_firmware_upgrade)
|
|
|
|
flash_upgrade(card, 3);
|
|
|
|
|
2010-12-08 20:40:47 +01:00
|
|
|
err = atm_init(card, &dev->dev);
|
2009-01-27 04:16:12 +01:00
|
|
|
if (err)
|
|
|
|
goto out_free_irq;
|
|
|
|
|
2012-12-19 12:01:18 +01:00
|
|
|
if (card->fpga_version >= DMA_SUPPORTED &&
|
|
|
|
sysfs_create_group(&card->dev->dev.kobj, &gpio_attr_group))
|
|
|
|
dev_err(&card->dev->dev, "Could not register parameter group for GPIOs\n");
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
return 0;
|
|
|
|
|
2009-01-27 04:16:12 +01:00
|
|
|
out_free_irq:
|
|
|
|
iowrite32(0, card->config_regs + IRQ_EN_ADDR);
|
|
|
|
free_irq(dev->irq, card);
|
|
|
|
tasklet_kill(&card->tlet);
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
out_unmap_both:
|
2012-12-19 12:01:21 +01:00
|
|
|
kfree(card->dma_bounce);
|
2008-12-23 05:09:02 +01:00
|
|
|
pci_iounmap(dev, card->buffers);
|
2012-02-19 10:43:32 +01:00
|
|
|
out_unmap_config:
|
|
|
|
pci_iounmap(dev, card->config_regs);
|
2008-12-23 05:09:02 +01:00
|
|
|
out_release_regions:
|
|
|
|
pci_release_regions(dev);
|
|
|
|
out:
|
2009-02-09 02:00:02 +01:00
|
|
|
kfree(card);
|
2008-12-23 05:09:02 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-12-08 20:40:47 +01:00
|
|
|
static int atm_init(struct solos_card *card, struct device *parent)
|
2008-12-23 05:09:02 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < card->nr_ports; i++) {
|
2009-01-27 10:02:30 +01:00
|
|
|
struct sk_buff *skb;
|
|
|
|
struct pkt_hdr *header;
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
skb_queue_head_init(&card->tx_queue[i]);
|
|
|
|
skb_queue_head_init(&card->cli_queue[i]);
|
|
|
|
|
2010-12-08 20:40:47 +01:00
|
|
|
card->atmdev[i] = atm_dev_register("solos-pci", parent, &fpga_ops, -1, NULL);
|
2008-12-23 05:09:02 +01:00
|
|
|
if (!card->atmdev[i]) {
|
|
|
|
dev_err(&card->dev->dev, "Could not register ATM device %d\n", i);
|
|
|
|
atm_remove(card);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
if (device_create_file(&card->atmdev[i]->class_dev, &dev_attr_console))
|
|
|
|
dev_err(&card->dev->dev, "Could not register console for ATM device %d\n", i);
|
2009-01-27 06:52:07 +01:00
|
|
|
if (sysfs_create_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group))
|
|
|
|
dev_err(&card->dev->dev, "Could not register parameter group for ATM device %d\n", i);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
|
|
|
dev_info(&card->dev->dev, "Registered ATM device %d\n", card->atmdev[i]->number);
|
|
|
|
|
|
|
|
card->atmdev[i]->ci_range.vpi_bits = 8;
|
|
|
|
card->atmdev[i]->ci_range.vci_bits = 16;
|
|
|
|
card->atmdev[i]->dev_data = card;
|
|
|
|
card->atmdev[i]->phy_data = (void *)(unsigned long)i;
|
2011-03-30 15:17:04 +02:00
|
|
|
atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND);
|
2009-01-27 10:02:30 +01:00
|
|
|
|
2012-11-30 00:27:20 +01:00
|
|
|
skb = alloc_skb(sizeof(*header), GFP_KERNEL);
|
2009-01-27 10:02:30 +01:00
|
|
|
if (!skb) {
|
|
|
|
dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *,
and in many places that means casts are required, more often than not.
Make these functions (skb_put, __skb_put and pskb_put) return void *
and remove all the casts across the tree, adding a (u8 *) cast only
where the unsigned char pointer was used directly, all done with the
following spatch:
@@
expression SKB, LEN;
typedef u8;
identifier fn = { skb_put, __skb_put };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_put, __skb_put };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
which actually doesn't cover pskb_put since there are only three
users overall.
A handful of stragglers were converted manually, notably a macro in
drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many
instances in net/bluetooth/hci_sock.c. In the former file, I also
had to fix one whitespace problem spatch introduced.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 14:29:21 +02:00
|
|
|
header = skb_put(skb, sizeof(*header));
|
2009-01-27 10:02:30 +01:00
|
|
|
|
|
|
|
header->size = cpu_to_le16(0);
|
|
|
|
header->vpi = cpu_to_le16(0);
|
|
|
|
header->vci = cpu_to_le16(0);
|
|
|
|
header->type = cpu_to_le16(PKT_STATUS);
|
|
|
|
|
|
|
|
fpga_queue(card, i, skb, NULL);
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void atm_remove(struct solos_card *card)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < card->nr_ports; i++) {
|
|
|
|
if (card->atmdev[i]) {
|
2009-03-17 15:59:34 +01:00
|
|
|
struct sk_buff *skb;
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
dev_info(&card->dev->dev, "Unregistering ATM device %d\n", card->atmdev[i]->number);
|
2009-01-28 04:34:34 +01:00
|
|
|
|
|
|
|
sysfs_remove_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group);
|
2008-12-23 05:09:02 +01:00
|
|
|
atm_dev_deregister(card->atmdev[i]);
|
2009-03-17 15:59:34 +01:00
|
|
|
|
|
|
|
skb = card->rx_skb[i];
|
|
|
|
if (skb) {
|
2015-01-16 14:57:21 +01:00
|
|
|
dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr,
|
|
|
|
RX_DMA_SIZE, DMA_FROM_DEVICE);
|
2009-03-17 15:59:34 +01:00
|
|
|
dev_kfree_skb(skb);
|
|
|
|
}
|
|
|
|
skb = card->tx_skb[i];
|
|
|
|
if (skb) {
|
2015-01-16 14:57:21 +01:00
|
|
|
dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr,
|
|
|
|
skb->len, DMA_TO_DEVICE);
|
2009-03-17 15:59:34 +01:00
|
|
|
dev_kfree_skb(skb);
|
|
|
|
}
|
|
|
|
while ((skb = skb_dequeue(&card->tx_queue[i])))
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fpga_remove(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
struct solos_card *card = pci_get_drvdata(dev);
|
2009-03-17 15:59:34 +01:00
|
|
|
|
|
|
|
/* Disable IRQs */
|
|
|
|
iowrite32(0, card->config_regs + IRQ_EN_ADDR);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2009-03-17 15:59:34 +01:00
|
|
|
/* Reset FPGA */
|
|
|
|
iowrite32(1, card->config_regs + FPGA_MODE);
|
|
|
|
(void)ioread32(card->config_regs + FPGA_MODE);
|
2008-12-23 05:09:02 +01:00
|
|
|
|
2012-12-19 12:01:18 +01:00
|
|
|
if (card->fpga_version >= DMA_SUPPORTED)
|
|
|
|
sysfs_remove_group(&card->dev->dev.kobj, &gpio_attr_group);
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
atm_remove(card);
|
|
|
|
|
|
|
|
free_irq(dev->irq, card);
|
|
|
|
tasklet_kill(&card->tlet);
|
|
|
|
|
2012-12-19 12:01:21 +01:00
|
|
|
kfree(card->dma_bounce);
|
|
|
|
|
2009-03-17 15:59:34 +01:00
|
|
|
/* Release device from reset */
|
|
|
|
iowrite32(0, card->config_regs + FPGA_MODE);
|
|
|
|
(void)ioread32(card->config_regs + FPGA_MODE);
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
pci_iounmap(dev, card->buffers);
|
|
|
|
pci_iounmap(dev, card->config_regs);
|
|
|
|
|
|
|
|
pci_release_regions(dev);
|
|
|
|
pci_disable_device(dev);
|
|
|
|
|
|
|
|
kfree(card);
|
|
|
|
}
|
|
|
|
|
2017-07-16 11:32:35 +02:00
|
|
|
static const struct pci_device_id fpga_pci_tbl[] = {
|
2008-12-23 05:09:02 +01:00
|
|
|
{ 0x10ee, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
|
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci,fpga_pci_tbl);
|
|
|
|
|
|
|
|
static struct pci_driver fpga_driver = {
|
|
|
|
.name = "solos",
|
|
|
|
.id_table = fpga_pci_tbl,
|
|
|
|
.probe = fpga_probe,
|
|
|
|
.remove = fpga_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int __init solos_pci_init(void)
|
|
|
|
{
|
2012-11-28 00:49:24 +01:00
|
|
|
BUILD_BUG_ON(sizeof(struct solos_skb_cb) > sizeof(((struct sk_buff *)0)->cb));
|
|
|
|
|
2008-12-23 05:09:02 +01:00
|
|
|
printk(KERN_INFO "Solos PCI Driver Version %s\n", VERSION);
|
|
|
|
return pci_register_driver(&fpga_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit solos_pci_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&fpga_driver);
|
|
|
|
printk(KERN_INFO "Solos PCI Driver %s Unloaded\n", VERSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(solos_pci_init);
|
|
|
|
module_exit(solos_pci_exit);
|