提交 e1f1f073 编写于 作者: L Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6:
  Staging: sep: remove driver
  Staging: batman-adv: Don't write in not allocated packet_buff
  Staging: batman-adv: Don't use net_dev after dev_put
  Staging: batman-adv: Create batman_if only on register event
  Staging: batman-adv: fix own mac address detection
  Staging: batman-adv: always reply batman icmp packets with primary mac
  Staging: batman-adv: fix batman icmp originating from secondary interface
  Staging: batman-adv: unify orig_hash_lock spinlock handling to avoid deadlocks
  Staging: batman-adv: Fix merge of linus tree
  Staging: spectra: removes unused functions
  Staging: spectra: initializa lblk variable
  Staging: spectra: removes unused variable
  Staging: spectra: remove duplicate GLOB_VERSION definition
  Staging: spectra: don't use locked_ioctl, fix build
  Staging: use new REQ_FLUSH flag, fix build breakage
  Staging: spectra: removes q->prepare_flush_fn, fix build breakage
......@@ -113,8 +113,6 @@ source "drivers/staging/vme/Kconfig"
source "drivers/staging/memrar/Kconfig"
source "drivers/staging/sep/Kconfig"
source "drivers/staging/iio/Kconfig"
source "drivers/staging/zram/Kconfig"
......
......@@ -38,7 +38,6 @@ obj-$(CONFIG_FB_UDL) += udlfb/
obj-$(CONFIG_HYPERV) += hv/
obj-$(CONFIG_VME_BUS) += vme/
obj-$(CONFIG_MRST_RAR_HANDLER) += memrar/
obj-$(CONFIG_DX_SEP) += sep/
obj-$(CONFIG_IIO) += iio/
obj-$(CONFIG_ZRAM) += zram/
obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/
......
......@@ -267,6 +267,10 @@ static ssize_t store_log_level(struct kobject *kobj, struct attribute *attr,
if (atomic_read(&bat_priv->log_level) == log_level_tmp)
return count;
bat_info(net_dev, "Changing log level from: %i to: %li\n",
atomic_read(&bat_priv->log_level),
log_level_tmp);
atomic_set(&bat_priv->log_level, (unsigned)log_level_tmp);
return count;
}
......
......@@ -129,6 +129,9 @@ static bool hardif_is_iface_up(struct batman_if *batman_if)
static void update_mac_addresses(struct batman_if *batman_if)
{
if (!batman_if || !batman_if->packet_buff)
return;
addr_to_string(batman_if->addr_str, batman_if->net_dev->dev_addr);
memcpy(((struct batman_packet *)(batman_if->packet_buff))->orig,
......@@ -194,8 +197,6 @@ static void hardif_activate_interface(struct net_device *net_dev,
if (batman_if->if_status != IF_INACTIVE)
return;
dev_hold(batman_if->net_dev);
update_mac_addresses(batman_if);
batman_if->if_status = IF_TO_BE_ACTIVATED;
......@@ -222,8 +223,6 @@ static void hardif_deactivate_interface(struct net_device *net_dev,
(batman_if->if_status != IF_TO_BE_ACTIVATED))
return;
dev_put(batman_if->net_dev);
batman_if->if_status = IF_INACTIVE;
bat_info(net_dev, "Interface deactivated: %s\n", batman_if->dev);
......@@ -318,11 +317,13 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
if (ret != 1)
goto out;
dev_hold(net_dev);
batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
if (!batman_if) {
pr_err("Can't add interface (%s): out of memory\n",
net_dev->name);
goto out;
goto release_dev;
}
batman_if->dev = kstrdup(net_dev->name, GFP_ATOMIC);
......@@ -336,6 +337,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
batman_if->if_num = -1;
batman_if->net_dev = net_dev;
batman_if->if_status = IF_NOT_IN_USE;
batman_if->packet_buff = NULL;
INIT_LIST_HEAD(&batman_if->list);
check_known_mac_addr(batman_if->net_dev->dev_addr);
......@@ -346,6 +348,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
kfree(batman_if->dev);
free_if:
kfree(batman_if);
release_dev:
dev_put(net_dev);
out:
return NULL;
}
......@@ -374,6 +378,7 @@ static void hardif_remove_interface(struct batman_if *batman_if)
batman_if->if_status = IF_TO_BE_REMOVED;
list_del_rcu(&batman_if->list);
sysfs_del_hardif(&batman_if->hardif_obj);
dev_put(batman_if->net_dev);
call_rcu(&batman_if->rcu, hardif_free_interface);
}
......@@ -393,15 +398,13 @@ static int hard_if_event(struct notifier_block *this,
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
if (!batman_if)
batman_if = hardif_add_interface(net_dev);
if (!batman_if && event == NETDEV_REGISTER)
batman_if = hardif_add_interface(net_dev);
if (!batman_if)
goto out;
switch (event) {
case NETDEV_REGISTER:
break;
case NETDEV_UP:
hardif_activate_interface(soft_device, bat_priv, batman_if);
break;
......@@ -442,8 +445,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct batman_packet *batman_packet;
struct batman_if *batman_if;
struct net_device_stats *stats;
struct rtnl_link_stats64 temp;
int ret;
skb = skb_share_check(skb, GFP_ATOMIC);
......@@ -479,12 +480,6 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
if (batman_if->if_status != IF_ACTIVE)
goto err_free;
stats = (struct net_device_stats *)dev_get_stats(skb->dev, &temp);
if (stats) {
stats->rx_packets++;
stats->rx_bytes += skb->len;
}
batman_packet = (struct batman_packet *)skb->data;
if (batman_packet->version != COMPAT_VERSION) {
......
......@@ -67,6 +67,7 @@ static int bat_socket_open(struct inode *inode, struct file *file)
INIT_LIST_HEAD(&socket_client->queue_list);
socket_client->queue_len = 0;
socket_client->index = i;
socket_client->bat_priv = inode->i_private;
spin_lock_init(&socket_client->lock);
init_waitqueue_head(&socket_client->queue_wait);
......@@ -151,9 +152,8 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf,
static ssize_t bat_socket_write(struct file *file, const char __user *buff,
size_t len, loff_t *off)
{
/* FIXME: each orig_node->batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct socket_client *socket_client = file->private_data;
struct bat_priv *bat_priv = socket_client->bat_priv;
struct icmp_packet_rr icmp_packet;
struct orig_node *orig_node;
struct batman_if *batman_if;
......@@ -168,6 +168,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
return -EINVAL;
}
if (!bat_priv->primary_if)
return -EFAULT;
if (len >= sizeof(struct icmp_packet_rr))
packet_len = sizeof(struct icmp_packet_rr);
......@@ -223,7 +226,8 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
if (batman_if->if_status != IF_ACTIVE)
goto dst_unreach;
memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, ETH_ALEN);
memcpy(icmp_packet.orig,
bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
if (packet_len == sizeof(struct icmp_packet_rr))
memcpy(icmp_packet.rr, batman_if->net_dev->dev_addr, ETH_ALEN);
......@@ -271,7 +275,7 @@ int bat_socket_setup(struct bat_priv *bat_priv)
goto err;
d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR,
bat_priv->debug_dir, NULL, &fops);
bat_priv->debug_dir, bat_priv, &fops);
if (d)
goto err;
......
......@@ -250,10 +250,13 @@ int choose_orig(void *data, int32_t size)
int is_my_mac(uint8_t *addr)
{
struct batman_if *batman_if;
rcu_read_lock();
list_for_each_entry_rcu(batman_if, &if_list, list) {
if ((batman_if->net_dev) &&
(compare_orig(batman_if->net_dev->dev_addr, addr))) {
if (batman_if->if_status != IF_ACTIVE)
continue;
if (compare_orig(batman_if->net_dev->dev_addr, addr)) {
rcu_read_unlock();
return 1;
}
......
......@@ -391,11 +391,12 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
{
struct orig_node *orig_node;
unsigned long flags;
HASHIT(hashit);
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
* if_num */
spin_lock(&orig_hash_lock);
spin_lock_irqsave(&orig_hash_lock, flags);
while (hash_iterate(orig_hash, &hashit)) {
orig_node = hashit.bucket->data;
......@@ -404,11 +405,11 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
goto err;
}
spin_unlock(&orig_hash_lock);
spin_unlock_irqrestore(&orig_hash_lock, flags);
return 0;
err:
spin_unlock(&orig_hash_lock);
spin_unlock_irqrestore(&orig_hash_lock, flags);
return -ENOMEM;
}
......@@ -468,12 +469,13 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)
{
struct batman_if *batman_if_tmp;
struct orig_node *orig_node;
unsigned long flags;
HASHIT(hashit);
int ret;
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
* if_num */
spin_lock(&orig_hash_lock);
spin_lock_irqsave(&orig_hash_lock, flags);
while (hash_iterate(orig_hash, &hashit)) {
orig_node = hashit.bucket->data;
......@@ -500,10 +502,10 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)
rcu_read_unlock();
batman_if->if_num = -1;
spin_unlock(&orig_hash_lock);
spin_unlock_irqrestore(&orig_hash_lock, flags);
return 0;
err:
spin_unlock(&orig_hash_lock);
spin_unlock_irqrestore(&orig_hash_lock, flags);
return -ENOMEM;
}
......@@ -783,6 +783,8 @@ int recv_bat_packet(struct sk_buff *skb,
static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
{
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct orig_node *orig_node;
struct icmp_packet_rr *icmp_packet;
struct ethhdr *ethhdr;
......@@ -801,6 +803,9 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
return NET_RX_DROP;
}
if (!bat_priv->primary_if)
return NET_RX_DROP;
/* answer echo request (ping) */
/* get routing information */
spin_lock_irqsave(&orig_hash_lock, flags);
......@@ -830,7 +835,8 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
}
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig, ethhdr->h_dest, ETH_ALEN);
memcpy(icmp_packet->orig,
bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = ECHO_REPLY;
icmp_packet->ttl = TTL;
......@@ -845,6 +851,8 @@ static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len)
static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
{
/* FIXME: each batman_if will be attached to a softif */
struct bat_priv *bat_priv = netdev_priv(soft_device);
struct orig_node *orig_node;
struct icmp_packet *icmp_packet;
struct ethhdr *ethhdr;
......@@ -865,6 +873,9 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
return NET_RX_DROP;
}
if (!bat_priv->primary_if)
return NET_RX_DROP;
/* get routing information */
spin_lock_irqsave(&orig_hash_lock, flags);
orig_node = ((struct orig_node *)
......@@ -892,7 +903,8 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len)
}
memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
memcpy(icmp_packet->orig, ethhdr->h_dest, ETH_ALEN);
memcpy(icmp_packet->orig,
bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
icmp_packet->msg_type = TTL_EXCEEDED;
icmp_packet->ttl = TTL;
......
......@@ -126,6 +126,7 @@ struct socket_client {
unsigned char index;
spinlock_t lock;
wait_queue_head_t queue_wait;
struct bat_priv *bat_priv;
};
struct socket_packet {
......
config DX_SEP
tristate "Discretix SEP driver"
# depends on MRST
depends on RAR_REGISTER && PCI
default y
help
Discretix SEP driver
If unsure say M. The compiled module will be
called sep_driver.ko
obj-$(CONFIG_DX_SEP) := sep_driver.o
Todo's so far (from Alan Cox)
- Fix firmware loading
- Get firmware into firmware git tree
- Review and tidy each algorithm function
- Check whether it can be plugged into any of the kernel crypto API
interfaces
- Do something about the magic shared memory interface and replace it
with something saner (in Linux terms)
#ifndef __SEP_DEV_H__
#define __SEP_DEV_H__
/*
*
* sep_dev.h - Security Processor Device Structures
*
* Copyright(c) 2009 Intel Corporation. All rights reserved.
* Copyright(c) 2009 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* CONTACTS:
*
* Alan Cox alan@linux.intel.com
*
*/
struct sep_device {
/* pointer to pci dev */
struct pci_dev *pdev;
unsigned long in_use;
/* address of the shared memory allocated during init for SEP driver
(coherent alloc) */
void *shared_addr;
/* the physical address of the shared area */
dma_addr_t shared_bus;
/* restricted access region (coherent alloc) */
dma_addr_t rar_bus;
void *rar_addr;
/* firmware regions: cache is at rar_addr */
unsigned long cache_size;
/* follows the cache */
dma_addr_t resident_bus;
unsigned long resident_size;
void *resident_addr;
/* start address of the access to the SEP registers from driver */
void __iomem *reg_addr;
/* transaction counter that coordinates the transactions between SEP and HOST */
unsigned long send_ct;
/* counter for the messages from sep */
unsigned long reply_ct;
/* counter for the number of bytes allocated in the pool for the current
transaction */
unsigned long data_pool_bytes_allocated;
/* array of pointers to the pages that represent input data for the synchronic
DMA action */
struct page **in_page_array;
/* array of pointers to the pages that represent out data for the synchronic
DMA action */
struct page **out_page_array;
/* number of pages in the sep_in_page_array */
unsigned long in_num_pages;
/* number of pages in the sep_out_page_array */
unsigned long out_num_pages;
/* global data for every flow */
struct sep_flow_context_t flows[SEP_DRIVER_NUM_FLOWS];
/* pointer to the workqueue that handles the flow done interrupts */
struct workqueue_struct *flow_wq;
};
static struct sep_device *sep_dev;
static inline void sep_write_reg(struct sep_device *dev, int reg, u32 value)
{
void __iomem *addr = dev->reg_addr + reg;
writel(value, addr);
}
static inline u32 sep_read_reg(struct sep_device *dev, int reg)
{
void __iomem *addr = dev->reg_addr + reg;
return readl(addr);
}
/* wait for SRAM write complete(indirect write */
static inline void sep_wait_sram_write(struct sep_device *dev)
{
u32 reg_val;
do
reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);
while (!(reg_val & 1));
}
#endif
此差异已折叠。
/*
*
* sep_driver_api.h - Security Processor Driver api definitions
*
* Copyright(c) 2009 Intel Corporation. All rights reserved.
* Copyright(c) 2009 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* CONTACTS:
*
* Mark Allyn mark.a.allyn@intel.com
*
* CHANGES:
*
* 2009.06.26 Initial publish
*
*/
#ifndef __SEP_DRIVER_API_H__
#define __SEP_DRIVER_API_H__
/*----------------------------------------------------------------
IOCTL command defines
-----------------------------------------------------------------*/
/* magic number 1 of the sep IOCTL command */
#define SEP_IOC_MAGIC_NUMBER 's'
/* sends interrupt to sep that message is ready */
#define SEP_IOCSENDSEPCOMMAND _IO(SEP_IOC_MAGIC_NUMBER , 0)
/* sends interrupt to sep that message is ready */
#define SEP_IOCSENDSEPRPLYCOMMAND _IO(SEP_IOC_MAGIC_NUMBER , 1)
/* allocate memory in data pool */
#define SEP_IOCALLOCDATAPOLL _IO(SEP_IOC_MAGIC_NUMBER , 2)
/* write to pre-allocated memory in data pool */
#define SEP_IOCWRITEDATAPOLL _IO(SEP_IOC_MAGIC_NUMBER , 3)
/* read from pre-allocated memory in data pool */
#define SEP_IOCREADDATAPOLL _IO(SEP_IOC_MAGIC_NUMBER , 4)
/* create sym dma lli tables */
#define SEP_IOCCREATESYMDMATABLE _IO(SEP_IOC_MAGIC_NUMBER , 5)
/* create flow dma lli tables */
#define SEP_IOCCREATEFLOWDMATABLE _IO(SEP_IOC_MAGIC_NUMBER , 6)
/* free dynamic data aalocated during table creation */
#define SEP_IOCFREEDMATABLEDATA _IO(SEP_IOC_MAGIC_NUMBER , 7)
/* get the static pool area addresses (physical and virtual) */
#define SEP_IOCGETSTATICPOOLADDR _IO(SEP_IOC_MAGIC_NUMBER , 8)
/* set flow id command */
#define SEP_IOCSETFLOWID _IO(SEP_IOC_MAGIC_NUMBER , 9)
/* add tables to the dynamic flow */
#define SEP_IOCADDFLOWTABLE _IO(SEP_IOC_MAGIC_NUMBER , 10)
/* add flow add tables message */
#define SEP_IOCADDFLOWMESSAGE _IO(SEP_IOC_MAGIC_NUMBER , 11)
/* start sep command */
#define SEP_IOCSEPSTART _IO(SEP_IOC_MAGIC_NUMBER , 12)
/* init sep command */
#define SEP_IOCSEPINIT _IO(SEP_IOC_MAGIC_NUMBER , 13)
/* end transaction command */
#define SEP_IOCENDTRANSACTION _IO(SEP_IOC_MAGIC_NUMBER , 15)
/* reallocate cache and resident */
#define SEP_IOCREALLOCCACHERES _IO(SEP_IOC_MAGIC_NUMBER , 16)
/* get the offset of the address starting from the beginnnig of the map area */
#define SEP_IOCGETMAPPEDADDROFFSET _IO(SEP_IOC_MAGIC_NUMBER , 17)
/* get time address and value */
#define SEP_IOCGETIME _IO(SEP_IOC_MAGIC_NUMBER , 19)
/*-------------------------------------------
TYPEDEFS
----------------------------------------------*/
/*
init command struct
*/
struct sep_driver_init_t {
/* start of the 1G of the host memory address that SEP can access */
unsigned long message_addr;
/* start address of resident */
unsigned long message_size_in_words;
};
/*
realloc cache resident command
*/
struct sep_driver_realloc_cache_resident_t {
/* new cache address */
u64 new_cache_addr;
/* new resident address */
u64 new_resident_addr;
/* new resident address */
u64 new_shared_area_addr;
/* new base address */
u64 new_base_addr;
};
struct sep_driver_alloc_t {
/* virtual address of allocated space */
unsigned long offset;
/* physical address of allocated space */
unsigned long phys_address;
/* number of bytes to allocate */
unsigned long num_bytes;
};
/*
*/
struct sep_driver_write_t {
/* application space address */
unsigned long app_address;
/* address of the data pool */
unsigned long datapool_address;
/* number of bytes to write */
unsigned long num_bytes;
};
/*
*/
struct sep_driver_read_t {
/* application space address */
unsigned long app_address;
/* address of the data pool */
unsigned long datapool_address;
/* number of bytes to read */
unsigned long num_bytes;
};
/*
*/
struct sep_driver_build_sync_table_t {
/* address value of the data in */
unsigned long app_in_address;
/* size of data in */
unsigned long data_in_size;
/* address of the data out */
unsigned long app_out_address;
/* the size of the block of the operation - if needed,
every table will be modulo this parameter */
unsigned long block_size;
/* the physical address of the first input DMA table */
unsigned long in_table_address;
/* number of entries in the first input DMA table */
unsigned long in_table_num_entries;
/* the physical address of the first output DMA table */
unsigned long out_table_address;
/* number of entries in the first output DMA table */
unsigned long out_table_num_entries;
/* data in the first input table */
unsigned long table_data_size;
/* distinct user/kernel layout */
bool isKernelVirtualAddress;
};
/*
*/
struct sep_driver_build_flow_table_t {
/* flow type */
unsigned long flow_type;
/* flag for input output */
unsigned long input_output_flag;
/* address value of the data in */
unsigned long virt_buff_data_addr;
/* size of data in */
unsigned long num_virtual_buffers;
/* the physical address of the first input DMA table */
unsigned long first_table_addr;
/* number of entries in the first input DMA table */
unsigned long first_table_num_entries;
/* data in the first input table */
unsigned long first_table_data_size;
/* distinct user/kernel layout */
bool isKernelVirtualAddress;
};
struct sep_driver_add_flow_table_t {
/* flow id */
unsigned long flow_id;
/* flag for input output */
unsigned long inputOutputFlag;
/* address value of the data in */
unsigned long virt_buff_data_addr;
/* size of data in */
unsigned long num_virtual_buffers;
/* address of the first table */
unsigned long first_table_addr;
/* number of entries in the first table */
unsigned long first_table_num_entries;
/* data size of the first table */
unsigned long first_table_data_size;
/* distinct user/kernel layout */
bool isKernelVirtualAddress;
};
/*
command struct for set flow id
*/
struct sep_driver_set_flow_id_t {
/* flow id to set */
unsigned long flow_id;
};
/* command struct for add tables message */
struct sep_driver_add_message_t {
/* flow id to set */
unsigned long flow_id;
/* message size in bytes */
unsigned long message_size_in_bytes;
/* address of the message */
unsigned long message_address;
};
/* command struct for static pool addresses */
struct sep_driver_static_pool_addr_t {
/* physical address of the static pool */
unsigned long physical_static_address;
/* virtual address of the static pool */
unsigned long virtual_static_address;
};
/* command struct for getiing offset of the physical address from
the start of the mapped area */
struct sep_driver_get_mapped_offset_t {
/* physical address of the static pool */
unsigned long physical_address;
/* virtual address of the static pool */
unsigned long offset;
};
/* command struct for getting time value and address */
struct sep_driver_get_time_t {
/* physical address of stored time */
unsigned long time_physical_address;
/* value of the stored time */
unsigned long time_value;
};
/*
structure that represent one entry in the DMA LLI table
*/
struct sep_lli_entry_t {
/* physical address */
unsigned long physical_address;
/* block size */
unsigned long block_size;
};
/*
structure that reperesents data needed for lli table construction
*/
struct sep_lli_prepare_table_data_t {
/* pointer to the memory where the first lli entry to be built */
struct sep_lli_entry_t *lli_entry_ptr;
/* pointer to the array of lli entries from which the table is to be built */
struct sep_lli_entry_t *lli_array_ptr;
/* number of elements in lli array */
int lli_array_size;
/* number of entries in the created table */
int num_table_entries;
/* number of array entries processed during table creation */
int num_array_entries_processed;
/* the totatl data size in the created table */
int lli_table_total_data_size;
};
/*
structure that represent tone table - it is not used in code, jkust
to show what table looks like
*/
struct sep_lli_table_t {
/* number of pages mapped in this tables. If 0 - means that the table
is not defined (used as a valid flag) */
unsigned long num_pages;
/*
pointer to array of page pointers that represent the mapping of the
virtual buffer defined by the table to the physical memory. If this
pointer is NULL, it means that the table is not defined
(used as a valid flag)
*/
struct page **table_page_array_ptr;
/* maximum flow entries in table */
struct sep_lli_entry_t lli_entries[SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE];
};
/*
structure for keeping the mapping of the virtual buffer into physical pages
*/
struct sep_flow_buffer_data {
/* pointer to the array of page structs pointers to the pages of the
virtual buffer */
struct page **page_array_ptr;
/* number of pages taken by the virtual buffer */
unsigned long num_pages;
/* this flag signals if this page_array is the last one among many that were
sent in one setting to SEP */
unsigned long last_page_array_flag;
};
/*
struct that keeps all the data for one flow
*/
struct sep_flow_context_t {
/*
work struct for handling the flow done interrupt in the workqueue
this structure must be in the first place, since it will be used
forcasting to the containing flow context
*/
struct work_struct flow_wq;
/* flow id */
unsigned long flow_id;
/* additional input tables exists */
unsigned long input_tables_flag;
/* additional output tables exists */
unsigned long output_tables_flag;
/* data of the first input file */
struct sep_lli_entry_t first_input_table;
/* data of the first output table */
struct sep_lli_entry_t first_output_table;
/* last input table data */
struct sep_lli_entry_t last_input_table;
/* last output table data */
struct sep_lli_entry_t last_output_table;
/* first list of table */
struct sep_lli_entry_t input_tables_in_process;
/* output table in process (in sep) */
struct sep_lli_entry_t output_tables_in_process;
/* size of messages in bytes */
unsigned long message_size_in_bytes;
/* message */
unsigned char message[SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES];
};
#endif
/*
*
* sep_driver_config.h - Security Processor Driver configuration
*
* Copyright(c) 2009 Intel Corporation. All rights reserved.
* Copyright(c) 2009 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* CONTACTS:
*
* Mark Allyn mark.a.allyn@intel.com
*
* CHANGES:
*
* 2009.06.26 Initial publish
*
*/
#ifndef __SEP_DRIVER_CONFIG_H__
#define __SEP_DRIVER_CONFIG_H__
/*--------------------------------------
DRIVER CONFIGURATION FLAGS
-------------------------------------*/
/* if flag is on , then the driver is running in polling and
not interrupt mode */
#define SEP_DRIVER_POLLING_MODE 1
/* flag which defines if the shared area address should be
reconfiged (send to SEP anew) during init of the driver */
#define SEP_DRIVER_RECONFIG_MESSAGE_AREA 0
/* the mode for running on the ARM1172 Evaluation platform (flag is 1) */
#define SEP_DRIVER_ARM_DEBUG_MODE 0
/*-------------------------------------------
INTERNAL DATA CONFIGURATION
-------------------------------------------*/
/* flag for the input array */
#define SEP_DRIVER_IN_FLAG 0
/* flag for output array */
#define SEP_DRIVER_OUT_FLAG 1
/* maximum number of entries in one LLI tables */
#define SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP 8
/*--------------------------------------------------------
SHARED AREA memory total size is 36K
it is divided is following:
SHARED_MESSAGE_AREA 8K }
}
STATIC_POOL_AREA 4K } MAPPED AREA ( 24 K)
}
DATA_POOL_AREA 12K }
SYNCHRONIC_DMA_TABLES_AREA 5K
FLOW_DMA_TABLES_AREA 4K
SYSTEM_MEMORY_AREA 3k
SYSTEM_MEMORY total size is 3k
it is divided as following:
TIME_MEMORY_AREA 8B
-----------------------------------------------------------*/
/*
the maximum length of the message - the rest of the message shared
area will be dedicated to the dma lli tables
*/
#define SEP_DRIVER_MAX_MESSAGE_SIZE_IN_BYTES (8 * 1024)
/* the size of the message shared area in pages */
#define SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES (8 * 1024)
/* the size of the data pool static area in pages */
#define SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES (4 * 1024)
/* the size of the data pool shared area size in pages */
#define SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES (12 * 1024)
/* the size of the message shared area in pages */
#define SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES (1024 * 5)
/* the size of the data pool shared area size in pages */
#define SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES (1024 * 4)
/* system data (time, caller id etc') pool */
#define SEP_DRIVER_SYSTEM_DATA_MEMORY_SIZE_IN_BYTES 100
/* area size that is mapped - we map the MESSAGE AREA, STATIC POOL and
DATA POOL areas. area must be module 4k */
#define SEP_DRIVER_MMMAP_AREA_SIZE (1024 * 24)
/*-----------------------------------------------
offsets of the areas starting from the shared area start address
*/
/* message area offset */
#define SEP_DRIVER_MESSAGE_AREA_OFFSET_IN_BYTES 0
/* static pool area offset */
#define SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES \
(SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES)
/* data pool area offset */
#define SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES \
(SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES + \
SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES)
/* synhronic dma tables area offset */
#define SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES \
(SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + \
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES)
/* sep driver flow dma tables area offset */
#define SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES \
(SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_OFFSET_IN_BYTES + \
SEP_DRIVER_SYNCHRONIC_DMA_TABLES_AREA_SIZE_IN_BYTES)
/* system memory offset in bytes */
#define SEP_DRIVER_SYSTEM_DATA_MEMORY_OFFSET_IN_BYTES \
(SEP_DRIVER_FLOW_DMA_TABLES_AREA_OFFSET_IN_BYTES + \
SEP_DRIVER_FLOW_DMA_TABLES_AREA_SIZE_IN_BYTES)
/* offset of the time area */
#define SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES \
(SEP_DRIVER_SYSTEM_DATA_MEMORY_OFFSET_IN_BYTES)
/* start physical address of the SEP registers memory in HOST */
#define SEP_IO_MEM_REGION_START_ADDRESS 0x80000000
/* size of the SEP registers memory region in HOST (for now 100 registers) */
#define SEP_IO_MEM_REGION_SIZE (2 * 0x100000)
/* define the number of IRQ for SEP interrupts */
#define SEP_DIRVER_IRQ_NUM 1
/* maximum number of add buffers */
#define SEP_MAX_NUM_ADD_BUFFERS 100
/* number of flows */
#define SEP_DRIVER_NUM_FLOWS 4
/* maximum number of entries in flow table */
#define SEP_DRIVER_MAX_FLOW_NUM_ENTRIES_IN_TABLE 25
/* offset of the num entries in the block length entry of the LLI */
#define SEP_NUM_ENTRIES_OFFSET_IN_BITS 24
/* offset of the interrupt flag in the block length entry of the LLI */
#define SEP_INT_FLAG_OFFSET_IN_BITS 31
/* mask for extracting data size from LLI */
#define SEP_TABLE_DATA_SIZE_MASK 0xFFFFFF
/* mask for entries after being shifted left */
#define SEP_NUM_ENTRIES_MASK 0x7F
/* default flow id */
#define SEP_FREE_FLOW_ID 0xFFFFFFFF
/* temp flow id used during cretiong of new flow until receiving
real flow id from sep */
#define SEP_TEMP_FLOW_ID (SEP_DRIVER_NUM_FLOWS + 1)
/* maximum add buffers message length in bytes */
#define SEP_MAX_ADD_MESSAGE_LENGTH_IN_BYTES (7 * 4)
/* maximum number of concurrent virtual buffers */
#define SEP_MAX_VIRT_BUFFERS_CONCURRENT 100
/* the token that defines the start of time address */
#define SEP_TIME_VAL_TOKEN 0x12345678
/* DEBUG LEVEL MASKS */
#define SEP_DEBUG_LEVEL_BASIC 0x1
#define SEP_DEBUG_LEVEL_EXTENDED 0x4
/* Debug helpers */
#define dbg(fmt, args...) \
do {\
if (debug & SEP_DEBUG_LEVEL_BASIC) \
printk(KERN_DEBUG fmt, ##args); \
} while(0);
#define edbg(fmt, args...) \
do { \
if (debug & SEP_DEBUG_LEVEL_EXTENDED) \
printk(KERN_DEBUG fmt, ##args); \
} while(0);
#endif
/*
*
* sep_driver_hw_defs.h - Security Processor Driver hardware definitions
*
* Copyright(c) 2009 Intel Corporation. All rights reserved.
* Copyright(c) 2009 Discretix. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* CONTACTS:
*
* Mark Allyn mark.a.allyn@intel.com
*
* CHANGES:
*
* 2009.06.26 Initial publish
*
*/
#ifndef SEP_DRIVER_HW_DEFS__H
#define SEP_DRIVER_HW_DEFS__H
/*--------------------------------------------------------------------------*/
/* Abstract: HW Registers Defines. */
/* */
/* Note: This file was automatically created !!! */
/* DO NOT EDIT THIS FILE !!! */
/*--------------------------------------------------------------------------*/
/* cf registers */
#define HW_R0B_ADDR_0_REG_ADDR 0x0000UL
#define HW_R0B_ADDR_1_REG_ADDR 0x0004UL
#define HW_R0B_ADDR_2_REG_ADDR 0x0008UL
#define HW_R0B_ADDR_3_REG_ADDR 0x000cUL
#define HW_R0B_ADDR_4_REG_ADDR 0x0010UL
#define HW_R0B_ADDR_5_REG_ADDR 0x0014UL
#define HW_R0B_ADDR_6_REG_ADDR 0x0018UL
#define HW_R0B_ADDR_7_REG_ADDR 0x001cUL
#define HW_R0B_ADDR_8_REG_ADDR 0x0020UL
#define HW_R2B_ADDR_0_REG_ADDR 0x0080UL
#define HW_R2B_ADDR_1_REG_ADDR 0x0084UL
#define HW_R2B_ADDR_2_REG_ADDR 0x0088UL
#define HW_R2B_ADDR_3_REG_ADDR 0x008cUL
#define HW_R2B_ADDR_4_REG_ADDR 0x0090UL
#define HW_R2B_ADDR_5_REG_ADDR 0x0094UL
#define HW_R2B_ADDR_6_REG_ADDR 0x0098UL
#define HW_R2B_ADDR_7_REG_ADDR 0x009cUL
#define HW_R2B_ADDR_8_REG_ADDR 0x00a0UL
#define HW_R3B_REG_ADDR 0x00C0UL
#define HW_R4B_REG_ADDR 0x0100UL
#define HW_CSA_ADDR_0_REG_ADDR 0x0140UL
#define HW_CSA_ADDR_1_REG_ADDR 0x0144UL
#define HW_CSA_ADDR_2_REG_ADDR 0x0148UL
#define HW_CSA_ADDR_3_REG_ADDR 0x014cUL
#define HW_CSA_ADDR_4_REG_ADDR 0x0150UL
#define HW_CSA_ADDR_5_REG_ADDR 0x0154UL
#define HW_CSA_ADDR_6_REG_ADDR 0x0158UL
#define HW_CSA_ADDR_7_REG_ADDR 0x015cUL
#define HW_CSA_ADDR_8_REG_ADDR 0x0160UL
#define HW_CSA_REG_ADDR 0x0140UL
#define HW_SINB_REG_ADDR 0x0180UL
#define HW_SOUTB_REG_ADDR 0x0184UL
#define HW_PKI_CONTROL_REG_ADDR 0x01C0UL
#define HW_PKI_STATUS_REG_ADDR 0x01C4UL
#define HW_PKI_BUSY_REG_ADDR 0x01C8UL
#define HW_PKI_A_1025_REG_ADDR 0x01CCUL
#define HW_PKI_SDMA_CTL_REG_ADDR 0x01D0UL
#define HW_PKI_SDMA_OFFSET_REG_ADDR 0x01D4UL
#define HW_PKI_SDMA_POINTERS_REG_ADDR 0x01D8UL
#define HW_PKI_SDMA_DLENG_REG_ADDR 0x01DCUL
#define HW_PKI_SDMA_EXP_POINTERS_REG_ADDR 0x01E0UL
#define HW_PKI_SDMA_RES_POINTERS_REG_ADDR 0x01E4UL
#define HW_PKI_CLR_REG_ADDR 0x01E8UL
#define HW_PKI_SDMA_BUSY_REG_ADDR 0x01E8UL
#define HW_PKI_SDMA_FIRST_EXP_N_REG_ADDR 0x01ECUL
#define HW_PKI_SDMA_MUL_BY1_REG_ADDR 0x01F0UL
#define HW_PKI_SDMA_RMUL_SEL_REG_ADDR 0x01F4UL
#define HW_DES_KEY_0_REG_ADDR 0x0208UL
#define HW_DES_KEY_1_REG_ADDR 0x020CUL
#define HW_DES_KEY_2_REG_ADDR 0x0210UL
#define HW_DES_KEY_3_REG_ADDR 0x0214UL
#define HW_DES_KEY_4_REG_ADDR 0x0218UL
#define HW_DES_KEY_5_REG_ADDR 0x021CUL
#define HW_DES_CONTROL_0_REG_ADDR 0x0220UL
#define HW_DES_CONTROL_1_REG_ADDR 0x0224UL
#define HW_DES_IV_0_REG_ADDR 0x0228UL
#define HW_DES_IV_1_REG_ADDR 0x022CUL
#define HW_AES_KEY_0_ADDR_0_REG_ADDR 0x0400UL
#define HW_AES_KEY_0_ADDR_1_REG_ADDR 0x0404UL
#define HW_AES_KEY_0_ADDR_2_REG_ADDR 0x0408UL
#define HW_AES_KEY_0_ADDR_3_REG_ADDR 0x040cUL
#define HW_AES_KEY_0_ADDR_4_REG_ADDR 0x0410UL
#define HW_AES_KEY_0_ADDR_5_REG_ADDR 0x0414UL
#define HW_AES_KEY_0_ADDR_6_REG_ADDR 0x0418UL
#define HW_AES_KEY_0_ADDR_7_REG_ADDR 0x041cUL
#define HW_AES_KEY_0_REG_ADDR 0x0400UL
#define HW_AES_IV_0_ADDR_0_REG_ADDR 0x0440UL
#define HW_AES_IV_0_ADDR_1_REG_ADDR 0x0444UL
#define HW_AES_IV_0_ADDR_2_REG_ADDR 0x0448UL
#define HW_AES_IV_0_ADDR_3_REG_ADDR 0x044cUL
#define HW_AES_IV_0_REG_ADDR 0x0440UL
#define HW_AES_CTR1_ADDR_0_REG_ADDR 0x0460UL
#define HW_AES_CTR1_ADDR_1_REG_ADDR 0x0464UL
#define HW_AES_CTR1_ADDR_2_REG_ADDR 0x0468UL
#define HW_AES_CTR1_ADDR_3_REG_ADDR 0x046cUL
#define HW_AES_CTR1_REG_ADDR 0x0460UL
#define HW_AES_SK_REG_ADDR 0x0478UL
#define HW_AES_MAC_OK_REG_ADDR 0x0480UL
#define HW_AES_PREV_IV_0_ADDR_0_REG_ADDR 0x0490UL
#define HW_AES_PREV_IV_0_ADDR_1_REG_ADDR 0x0494UL
#define HW_AES_PREV_IV_0_ADDR_2_REG_ADDR 0x0498UL
#define HW_AES_PREV_IV_0_ADDR_3_REG_ADDR 0x049cUL
#define HW_AES_PREV_IV_0_REG_ADDR 0x0490UL
#define HW_AES_CONTROL_REG_ADDR 0x04C0UL
#define HW_HASH_H0_REG_ADDR 0x0640UL
#define HW_HASH_H1_REG_ADDR 0x0644UL
#define HW_HASH_H2_REG_ADDR 0x0648UL
#define HW_HASH_H3_REG_ADDR 0x064CUL
#define HW_HASH_H4_REG_ADDR 0x0650UL
#define HW_HASH_H5_REG_ADDR 0x0654UL
#define HW_HASH_H6_REG_ADDR 0x0658UL
#define HW_HASH_H7_REG_ADDR 0x065CUL
#define HW_HASH_H8_REG_ADDR 0x0660UL
#define HW_HASH_H9_REG_ADDR 0x0664UL
#define HW_HASH_H10_REG_ADDR 0x0668UL
#define HW_HASH_H11_REG_ADDR 0x066CUL
#define HW_HASH_H12_REG_ADDR 0x0670UL
#define HW_HASH_H13_REG_ADDR 0x0674UL
#define HW_HASH_H14_REG_ADDR 0x0678UL
#define HW_HASH_H15_REG_ADDR 0x067CUL
#define HW_HASH_CONTROL_REG_ADDR 0x07C0UL
#define HW_HASH_PAD_EN_REG_ADDR 0x07C4UL
#define HW_HASH_PAD_CFG_REG_ADDR 0x07C8UL
#define HW_HASH_CUR_LEN_0_REG_ADDR 0x07CCUL
#define HW_HASH_CUR_LEN_1_REG_ADDR 0x07D0UL
#define HW_HASH_CUR_LEN_2_REG_ADDR 0x07D4UL
#define HW_HASH_CUR_LEN_3_REG_ADDR 0x07D8UL
#define HW_HASH_PARAM_REG_ADDR 0x07DCUL
#define HW_HASH_INT_BUSY_REG_ADDR 0x07E0UL
#define HW_HASH_SW_RESET_REG_ADDR 0x07E4UL
#define HW_HASH_ENDIANESS_REG_ADDR 0x07E8UL
#define HW_HASH_DATA_REG_ADDR 0x07ECUL
#define HW_DRNG_CONTROL_REG_ADDR 0x0800UL
#define HW_DRNG_VALID_REG_ADDR 0x0804UL
#define HW_DRNG_DATA_REG_ADDR 0x0808UL
#define HW_RND_SRC_EN_REG_ADDR 0x080CUL
#define HW_AES_CLK_ENABLE_REG_ADDR 0x0810UL
#define HW_DES_CLK_ENABLE_REG_ADDR 0x0814UL
#define HW_HASH_CLK_ENABLE_REG_ADDR 0x0818UL
#define HW_PKI_CLK_ENABLE_REG_ADDR 0x081CUL
#define HW_CLK_STATUS_REG_ADDR 0x0824UL
#define HW_CLK_ENABLE_REG_ADDR 0x0828UL
#define HW_DRNG_SAMPLE_REG_ADDR 0x0850UL
#define HW_RND_SRC_CTL_REG_ADDR 0x0858UL
#define HW_CRYPTO_CTL_REG_ADDR 0x0900UL
#define HW_CRYPTO_STATUS_REG_ADDR 0x090CUL
#define HW_CRYPTO_BUSY_REG_ADDR 0x0910UL
#define HW_AES_BUSY_REG_ADDR 0x0914UL
#define HW_DES_BUSY_REG_ADDR 0x0918UL
#define HW_HASH_BUSY_REG_ADDR 0x091CUL
#define HW_CONTENT_REG_ADDR 0x0924UL
#define HW_VERSION_REG_ADDR 0x0928UL
#define HW_CONTEXT_ID_REG_ADDR 0x0930UL
#define HW_DIN_BUFFER_REG_ADDR 0x0C00UL
#define HW_DIN_MEM_DMA_BUSY_REG_ADDR 0x0c20UL
#define HW_SRC_LLI_MEM_ADDR_REG_ADDR 0x0c24UL
#define HW_SRC_LLI_WORD0_REG_ADDR 0x0C28UL
#define HW_SRC_LLI_WORD1_REG_ADDR 0x0C2CUL
#define HW_SRAM_SRC_ADDR_REG_ADDR 0x0c30UL
#define HW_DIN_SRAM_BYTES_LEN_REG_ADDR 0x0c34UL
#define HW_DIN_SRAM_DMA_BUSY_REG_ADDR 0x0C38UL
#define HW_WRITE_ALIGN_REG_ADDR 0x0C3CUL
#define HW_OLD_DATA_REG_ADDR 0x0C48UL
#define HW_WRITE_ALIGN_LAST_REG_ADDR 0x0C4CUL
#define HW_DOUT_BUFFER_REG_ADDR 0x0C00UL
#define HW_DST_LLI_WORD0_REG_ADDR 0x0D28UL
#define HW_DST_LLI_WORD1_REG_ADDR 0x0D2CUL
#define HW_DST_LLI_MEM_ADDR_REG_ADDR 0x0D24UL
#define HW_DOUT_MEM_DMA_BUSY_REG_ADDR 0x0D20UL
#define HW_SRAM_DEST_ADDR_REG_ADDR 0x0D30UL
#define HW_DOUT_SRAM_BYTES_LEN_REG_ADDR 0x0D34UL
#define HW_DOUT_SRAM_DMA_BUSY_REG_ADDR 0x0D38UL
#define HW_READ_ALIGN_REG_ADDR 0x0D3CUL
#define HW_READ_LAST_DATA_REG_ADDR 0x0D44UL
#define HW_RC4_THRU_CPU_REG_ADDR 0x0D4CUL
#define HW_AHB_SINGLE_REG_ADDR 0x0E00UL
#define HW_SRAM_DATA_REG_ADDR 0x0F00UL
#define HW_SRAM_ADDR_REG_ADDR 0x0F04UL
#define HW_SRAM_DATA_READY_REG_ADDR 0x0F08UL
#define HW_HOST_IRR_REG_ADDR 0x0A00UL
#define HW_HOST_IMR_REG_ADDR 0x0A04UL
#define HW_HOST_ICR_REG_ADDR 0x0A08UL
#define HW_HOST_SEP_SRAM_THRESHOLD_REG_ADDR 0x0A10UL
#define HW_HOST_SEP_BUSY_REG_ADDR 0x0A14UL
#define HW_HOST_SEP_LCS_REG_ADDR 0x0A18UL
#define HW_HOST_CC_SW_RST_REG_ADDR 0x0A40UL
#define HW_HOST_SEP_SW_RST_REG_ADDR 0x0A44UL
#define HW_HOST_FLOW_DMA_SW_INT0_REG_ADDR 0x0A80UL
#define HW_HOST_FLOW_DMA_SW_INT1_REG_ADDR 0x0A84UL
#define HW_HOST_FLOW_DMA_SW_INT2_REG_ADDR 0x0A88UL
#define HW_HOST_FLOW_DMA_SW_INT3_REG_ADDR 0x0A8cUL
#define HW_HOST_FLOW_DMA_SW_INT4_REG_ADDR 0x0A90UL
#define HW_HOST_FLOW_DMA_SW_INT5_REG_ADDR 0x0A94UL
#define HW_HOST_FLOW_DMA_SW_INT6_REG_ADDR 0x0A98UL
#define HW_HOST_FLOW_DMA_SW_INT7_REG_ADDR 0x0A9cUL
#define HW_HOST_SEP_HOST_GPR0_REG_ADDR 0x0B00UL
#define HW_HOST_SEP_HOST_GPR1_REG_ADDR 0x0B04UL
#define HW_HOST_SEP_HOST_GPR2_REG_ADDR 0x0B08UL
#define HW_HOST_SEP_HOST_GPR3_REG_ADDR 0x0B0CUL
#define HW_HOST_HOST_SEP_GPR0_REG_ADDR 0x0B80UL
#define HW_HOST_HOST_SEP_GPR1_REG_ADDR 0x0B84UL
#define HW_HOST_HOST_SEP_GPR2_REG_ADDR 0x0B88UL
#define HW_HOST_HOST_SEP_GPR3_REG_ADDR 0x0B8CUL
#define HW_HOST_HOST_ENDIAN_REG_ADDR 0x0B90UL
#define HW_HOST_HOST_COMM_CLK_EN_REG_ADDR 0x0B94UL
#define HW_CLR_SRAM_BUSY_REG_REG_ADDR 0x0F0CUL
#define HW_CC_SRAM_BASE_ADDRESS 0x5800UL
#endif /* ifndef HW_DEFS */
......@@ -27,6 +27,7 @@
#include <linux/kthread.h>
#include <linux/log2.h>
#include <linux/init.h>
#include <linux/smp_lock.h>
/**** Helper functions used for Div, Remainder operation on u64 ****/
......@@ -113,7 +114,6 @@ u64 GLOB_u64_Remainder(u64 addr, u32 divisor_type)
#define GLOB_SBD_NAME "nd"
#define GLOB_SBD_IRQ_NUM (29)
#define GLOB_VERSION "driver version 20091110"
#define GLOB_SBD_IOCTL_GC (0x7701)
#define GLOB_SBD_IOCTL_WL (0x7702)
......@@ -272,13 +272,6 @@ static int get_res_blk_num_os(void)
return res_blks;
}
static void SBD_prepare_flush(struct request_queue *q, struct request *rq)
{
rq->cmd_type = REQ_TYPE_LINUX_BLOCK;
/* rq->timeout = 5 * HZ; */
rq->cmd[0] = REQ_LB_OP_FLUSH;
}
/* Transfer a full request. */
static int do_transfer(struct spectra_nand_dev *tr, struct request *req)
{
......@@ -296,8 +289,7 @@ static int do_transfer(struct spectra_nand_dev *tr, struct request *req)
IdentifyDeviceData.PagesPerBlock *
res_blks_os;
if (req->cmd_type == REQ_TYPE_LINUX_BLOCK &&
req->cmd[0] == REQ_LB_OP_FLUSH) {
if (req->cmd_type & REQ_FLUSH) {
if (force_flush_cache()) /* Fail to flush cache */
return -EIO;
else
......@@ -597,11 +589,23 @@ int GLOB_SBD_ioctl(struct block_device *bdev, fmode_t mode,
return -ENOTTY;
}
int GLOB_SBD_unlocked_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
int ret;
lock_kernel();
ret = GLOB_SBD_ioctl(bdev, mode, cmd, arg);
unlock_kernel();
return ret;
}
static struct block_device_operations GLOB_SBD_ops = {
.owner = THIS_MODULE,
.open = GLOB_SBD_open,
.release = GLOB_SBD_release,
.locked_ioctl = GLOB_SBD_ioctl,
.ioctl = GLOB_SBD_unlocked_ioctl,
.getgeo = GLOB_SBD_getgeo,
};
......@@ -650,8 +654,7 @@ static int SBD_setup_device(struct spectra_nand_dev *dev, int which)
/* Here we force report 512 byte hardware sector size to Kernel */
blk_queue_logical_block_size(dev->queue, 512);
blk_queue_ordered(dev->queue, QUEUE_ORDERED_DRAIN_FLUSH,
SBD_prepare_flush);
blk_queue_ordered(dev->queue, QUEUE_ORDERED_DRAIN_FLUSH);
dev->thread = kthread_run(spectra_trans_thread, dev, "nand_thd");
if (IS_ERR(dev->thread)) {
......
......@@ -61,7 +61,6 @@ static void FTL_Cache_Read_Page(u8 *pData, u64 dwPageAddr,
static void FTL_Cache_Write_Page(u8 *pData, u64 dwPageAddr,
u8 cache_blk, u16 flag);
static int FTL_Cache_Write(void);
static int FTL_Cache_Write_Back(u8 *pData, u64 blk_addr);
static void FTL_Calculate_LRU(void);
static u32 FTL_Get_Block_Index(u32 wBlockNum);
......@@ -86,8 +85,6 @@ static u32 FTL_Replace_MWBlock(void);
static int FTL_Replace_Block(u64 blk_addr);
static int FTL_Adjust_Relative_Erase_Count(u32 Index_of_MAX);
static int FTL_Flash_Error_Handle(u8 *pData, u64 old_page_addr, u64 blk_addr);
struct device_info_tag DeviceInfo;
struct flash_cache_tag Cache;
static struct spectra_l2_cache_info cache_l2;
......@@ -775,7 +772,7 @@ static void dump_cache_l2_table(void)
{
struct list_head *p;
struct spectra_l2_cache_list *pnd;
int n, i;
int n;
n = 0;
list_for_each(p, &cache_l2.table.list) {
......@@ -1537,79 +1534,6 @@ static int FTL_Cache_Write_All(u8 *pData, u64 blk_addr)
return wResult;
}
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function: FTL_Cache_Update_Block
* Inputs: pointer to buffer,page address,block address
* Outputs: PASS=0 / FAIL=1
* Description: It updates the cache
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
static int FTL_Cache_Update_Block(u8 *pData,
u64 old_page_addr, u64 blk_addr)
{
int i, j;
u8 *buf = pData;
int wResult = PASS;
int wFoundInCache;
u64 page_addr;
u64 addr;
u64 old_blk_addr;
u16 page_offset;
nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n",
__FILE__, __LINE__, __func__);
old_blk_addr = (u64)(old_page_addr >>
DeviceInfo.nBitsInBlockDataSize) * DeviceInfo.wBlockDataSize;
page_offset = (u16)(GLOB_u64_Remainder(old_page_addr, 2) >>
DeviceInfo.nBitsInPageDataSize);
for (i = 0; i < DeviceInfo.wPagesPerBlock; i += Cache.pages_per_item) {
page_addr = old_blk_addr + i * DeviceInfo.wPageDataSize;
if (i != page_offset) {
wFoundInCache = FAIL;
for (j = 0; j < CACHE_ITEM_NUM; j++) {
addr = Cache.array[j].address;
addr = FTL_Get_Physical_Block_Addr(addr) +
GLOB_u64_Remainder(addr, 2);
if ((addr >= page_addr) && addr <
(page_addr + Cache.cache_item_size)) {
wFoundInCache = PASS;
buf = Cache.array[j].buf;
Cache.array[j].changed = SET;
#if CMD_DMA
#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE
int_cache[ftl_cmd_cnt].item = j;
int_cache[ftl_cmd_cnt].cache.address =
Cache.array[j].address;
int_cache[ftl_cmd_cnt].cache.changed =
Cache.array[j].changed;
#endif
#endif
break;
}
}
if (FAIL == wFoundInCache) {
if (ERR == FTL_Cache_Read_All(g_pTempBuf,
page_addr)) {
wResult = FAIL;
break;
}
buf = g_pTempBuf;
}
} else {
buf = pData;
}
if (FAIL == FTL_Cache_Write_All(buf,
blk_addr + (page_addr - old_blk_addr))) {
wResult = FAIL;
break;
}
}
return wResult;
}
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function: FTL_Copy_Block
* Inputs: source block address
......@@ -1698,7 +1622,7 @@ static int get_l2_cache_blks(void)
static int erase_l2_cache_blocks(void)
{
int i, ret = PASS;
u32 pblk, lblk;
u32 pblk, lblk = BAD_BLOCK;
u64 addr;
u32 *pbt = (u32 *)g_pBlockTable;
......@@ -2004,87 +1928,6 @@ static int search_l2_cache(u8 *buf, u64 logical_addr)
return ret;
}
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function: FTL_Cache_Write_Back
* Inputs: pointer to data cached in sys memory
* address of free block in flash
* Outputs: PASS=0 / FAIL=1
* Description: writes all the pages of Cache Block to flash
*
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
static int FTL_Cache_Write_Back(u8 *pData, u64 blk_addr)
{
int i, j, iErase;
u64 old_page_addr, addr, phy_addr;
u32 *pbt = (u32 *)g_pBlockTable;
u32 lba;
nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n",
__FILE__, __LINE__, __func__);
old_page_addr = FTL_Get_Physical_Block_Addr(blk_addr) +
GLOB_u64_Remainder(blk_addr, 2);
iErase = (FAIL == FTL_Replace_Block(blk_addr)) ? PASS : FAIL;
pbt[BLK_FROM_ADDR(blk_addr)] &= (~SPARE_BLOCK);
#if CMD_DMA
p_BTableChangesDelta = (struct BTableChangesDelta *)g_pBTDelta_Free;
g_pBTDelta_Free += sizeof(struct BTableChangesDelta);
p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt;
p_BTableChangesDelta->BT_Index = (u32)(blk_addr >>
DeviceInfo.nBitsInBlockDataSize);
p_BTableChangesDelta->BT_Entry_Value =
pbt[(u32)(blk_addr >> DeviceInfo.nBitsInBlockDataSize)];
p_BTableChangesDelta->ValidFields = 0x0C;
#endif
if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) {
g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE;
FTL_Write_IN_Progress_Block_Table_Page();
}
for (i = 0; i < RETRY_TIMES; i++) {
if (PASS == iErase) {
phy_addr = FTL_Get_Physical_Block_Addr(blk_addr);
if (FAIL == GLOB_FTL_Block_Erase(phy_addr)) {
lba = BLK_FROM_ADDR(blk_addr);
MARK_BLOCK_AS_BAD(pbt[lba]);
i = RETRY_TIMES;
break;
}
}
for (j = 0; j < CACHE_ITEM_NUM; j++) {
addr = Cache.array[j].address;
if ((addr <= blk_addr) &&
((addr + Cache.cache_item_size) > blk_addr))
cache_block_to_write = j;
}
phy_addr = FTL_Get_Physical_Block_Addr(blk_addr);
if (PASS == FTL_Cache_Update_Block(pData,
old_page_addr, phy_addr)) {
cache_block_to_write = UNHIT_CACHE_ITEM;
break;
} else {
iErase = PASS;
}
}
if (i >= RETRY_TIMES) {
if (ERR == FTL_Flash_Error_Handle(pData,
old_page_addr, blk_addr))
return ERR;
else
return FAIL;
}
return PASS;
}
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function: FTL_Cache_Write_Page
* Inputs: Pointer to buffer, page address, cache block number
......@@ -2370,159 +2213,6 @@ static int FTL_Write_Block_Table(int wForce)
return 1;
}
/******************************************************************
* Function: GLOB_FTL_Flash_Format
* Inputs: none
* Outputs: PASS
* Description: The block table stores bad block info, including MDF+
* blocks gone bad over the ages. Therefore, if we have a
* block table in place, then use it to scan for bad blocks
* If not, then scan for MDF.
* Now, a block table will only be found if spectra was already
* being used. For a fresh flash, we'll go thru scanning for
* MDF. If spectra was being used, then there is a chance that
* the MDF has been corrupted. Spectra avoids writing to the
* first 2 bytes of the spare area to all pages in a block. This
* covers all known flash devices. However, since flash
* manufacturers have no standard of where the MDF is stored,
* this cannot guarantee that the MDF is protected for future
* devices too. The initial scanning for the block table assures
* this. It is ok even if the block table is outdated, as all
* we're looking for are bad block markers.
* Use this when mounting a file system or starting a
* new flash.
*
*********************************************************************/
static int FTL_Format_Flash(u8 valid_block_table)
{
u32 i, j;
u32 *pbt = (u32 *)g_pBlockTable;
u32 tempNode;
int ret;
#if CMD_DMA
u32 *pbtStartingCopy = (u32 *)g_pBTStartingCopy;
if (ftl_cmd_cnt)
return FAIL;
#endif
if (FAIL == FTL_Check_Block_Table(FAIL))
valid_block_table = 0;
if (valid_block_table) {
u8 switched = 1;
u32 block, k;
k = DeviceInfo.wSpectraStartBlock;
while (switched && (k < DeviceInfo.wSpectraEndBlock)) {
switched = 0;
k++;
for (j = DeviceInfo.wSpectraStartBlock, i = 0;
j <= DeviceInfo.wSpectraEndBlock;
j++, i++) {
block = (pbt[i] & ~BAD_BLOCK) -
DeviceInfo.wSpectraStartBlock;
if (block != i) {
switched = 1;
tempNode = pbt[i];
pbt[i] = pbt[block];
pbt[block] = tempNode;
}
}
}
if ((k == DeviceInfo.wSpectraEndBlock) && switched)
valid_block_table = 0;
}
if (!valid_block_table) {
memset(g_pBlockTable, 0,
DeviceInfo.wDataBlockNum * sizeof(u32));
memset(g_pWearCounter, 0,
DeviceInfo.wDataBlockNum * sizeof(u8));
if (DeviceInfo.MLCDevice)
memset(g_pReadCounter, 0,
DeviceInfo.wDataBlockNum * sizeof(u16));
#if CMD_DMA
memset(g_pBTStartingCopy, 0,
DeviceInfo.wDataBlockNum * sizeof(u32));
memset(g_pWearCounterCopy, 0,
DeviceInfo.wDataBlockNum * sizeof(u8));
if (DeviceInfo.MLCDevice)
memset(g_pReadCounterCopy, 0,
DeviceInfo.wDataBlockNum * sizeof(u16));
#endif
for (j = DeviceInfo.wSpectraStartBlock, i = 0;
j <= DeviceInfo.wSpectraEndBlock;
j++, i++) {
if (GLOB_LLD_Get_Bad_Block((u32)j))
pbt[i] = (u32)(BAD_BLOCK | j);
}
}
nand_dbg_print(NAND_DBG_WARN, "Erasing all blocks in the NAND\n");
for (j = DeviceInfo.wSpectraStartBlock, i = 0;
j <= DeviceInfo.wSpectraEndBlock;
j++, i++) {
if ((pbt[i] & BAD_BLOCK) != BAD_BLOCK) {
ret = GLOB_LLD_Erase_Block(j);
if (FAIL == ret) {
pbt[i] = (u32)(j);
MARK_BLOCK_AS_BAD(pbt[i]);
nand_dbg_print(NAND_DBG_WARN,
"NAND Program fail in %s, Line %d, "
"Function: %s, new Bad Block %d generated!\n",
__FILE__, __LINE__, __func__, (int)j);
} else {
pbt[i] = (u32)(SPARE_BLOCK | j);
}
}
#if CMD_DMA
pbtStartingCopy[i] = pbt[i];
#endif
}
g_wBlockTableOffset = 0;
for (i = 0; (i <= (DeviceInfo.wSpectraEndBlock -
DeviceInfo.wSpectraStartBlock))
&& ((pbt[i] & BAD_BLOCK) == BAD_BLOCK); i++)
;
if (i > (DeviceInfo.wSpectraEndBlock - DeviceInfo.wSpectraStartBlock)) {
printk(KERN_ERR "All blocks bad!\n");
return FAIL;
} else {
g_wBlockTableIndex = pbt[i] & ~BAD_BLOCK;
if (i != BLOCK_TABLE_INDEX) {
tempNode = pbt[i];
pbt[i] = pbt[BLOCK_TABLE_INDEX];
pbt[BLOCK_TABLE_INDEX] = tempNode;
}
}
pbt[BLOCK_TABLE_INDEX] &= (~SPARE_BLOCK);
#if CMD_DMA
pbtStartingCopy[BLOCK_TABLE_INDEX] &= (~SPARE_BLOCK);
#endif
g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE;
memset(g_pBTBlocks, 0xFF,
(1 + LAST_BT_ID - FIRST_BT_ID) * sizeof(u32));
g_pBTBlocks[FIRST_BT_ID-FIRST_BT_ID] = g_wBlockTableIndex;
FTL_Write_Block_Table(FAIL);
for (i = 0; i < CACHE_ITEM_NUM; i++) {
Cache.array[i].address = NAND_CACHE_INIT_ADDR;
Cache.array[i].use_cnt = 0;
Cache.array[i].changed = CLEAR;
}
#if (RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE && CMD_DMA)
memcpy((void *)&cache_start_copy, (void *)&Cache,
sizeof(struct flash_cache_tag));
#endif
return PASS;
}
static int force_format_nand(void)
{
u32 i;
......@@ -3031,112 +2721,6 @@ static int FTL_Read_Block_Table(void)
return wResult;
}
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function: FTL_Flash_Error_Handle
* Inputs: Pointer to data
* Page address
* Block address
* Outputs: PASS=0 / FAIL=1
* Description: It handles any error occured during Spectra operation
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
static int FTL_Flash_Error_Handle(u8 *pData, u64 old_page_addr,
u64 blk_addr)
{
u32 i;
int j;
u32 tmp_node, blk_node = BLK_FROM_ADDR(blk_addr);
u64 phy_addr;
int wErase = FAIL;
int wResult = FAIL;
u32 *pbt = (u32 *)g_pBlockTable;
nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n",
__FILE__, __LINE__, __func__);
if (ERR == GLOB_FTL_Garbage_Collection())
return ERR;
do {
for (i = DeviceInfo.wSpectraEndBlock -
DeviceInfo.wSpectraStartBlock;
i > 0; i--) {
if (IS_SPARE_BLOCK(i)) {
tmp_node = (u32)(BAD_BLOCK |
pbt[blk_node]);
pbt[blk_node] = (u32)(pbt[i] &
(~SPARE_BLOCK));
pbt[i] = tmp_node;
#if CMD_DMA
p_BTableChangesDelta =
(struct BTableChangesDelta *)
g_pBTDelta_Free;
g_pBTDelta_Free +=
sizeof(struct BTableChangesDelta);
p_BTableChangesDelta->ftl_cmd_cnt =
ftl_cmd_cnt;
p_BTableChangesDelta->BT_Index =
blk_node;
p_BTableChangesDelta->BT_Entry_Value =
pbt[blk_node];
p_BTableChangesDelta->ValidFields = 0x0C;
p_BTableChangesDelta =
(struct BTableChangesDelta *)
g_pBTDelta_Free;
g_pBTDelta_Free +=
sizeof(struct BTableChangesDelta);
p_BTableChangesDelta->ftl_cmd_cnt =
ftl_cmd_cnt;
p_BTableChangesDelta->BT_Index = i;
p_BTableChangesDelta->BT_Entry_Value = pbt[i];
p_BTableChangesDelta->ValidFields = 0x0C;
#endif
wResult = PASS;
break;
}
}
if (FAIL == wResult) {
if (FAIL == GLOB_FTL_Garbage_Collection())
break;
else
continue;
}
if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) {
g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE;
FTL_Write_IN_Progress_Block_Table_Page();
}
phy_addr = FTL_Get_Physical_Block_Addr(blk_addr);
for (j = 0; j < RETRY_TIMES; j++) {
if (PASS == wErase) {
if (FAIL == GLOB_FTL_Block_Erase(phy_addr)) {
MARK_BLOCK_AS_BAD(pbt[blk_node]);
break;
}
}
if (PASS == FTL_Cache_Update_Block(pData,
old_page_addr,
phy_addr)) {
wResult = PASS;
break;
} else {
wResult = FAIL;
wErase = PASS;
}
}
} while (FAIL == wResult);
FTL_Write_Block_Table(FAIL);
return wResult;
}
/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Function: FTL_Get_Page_Num
* Inputs: Size in bytes
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册