Skip to content

Commit

Permalink
[SCSI] be2iscsi: add 10Gbps iSCSI - BladeEngine 2 driver
Browse files Browse the repository at this point in the history
[v2: fixed up virt_to_bus() issue spotted by sfr]
Signed-off-by: Mike Christie <[email protected]>
Signed-off-by: Jayamohan Kallickal <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
Jayamohan Kallickal authored and James Bottomley committed Oct 2, 2009
1 parent d74cf7c commit 6733b39
Show file tree
Hide file tree
Showing 14 changed files with 7,126 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -4625,6 +4625,14 @@ F: drivers/ata/
F: include/linux/ata.h
F: include/linux/libata.h

SERVER ENGINES 10Gbps iSCSI - BladeEngine 2 DRIVER
P: Jayamohan Kallickal
M: [email protected]
L: [email protected]
W: http://www.serverengines.com
S: Supported
F: drivers/scsi/be2iscsi/

SERVER ENGINES 10Gbps NIC - BladeEngine 2 DRIVER
M: Sathya Perla <[email protected]>
M: Subbu Seetharaman <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ config ISCSI_TCP

source "drivers/scsi/cxgb3i/Kconfig"
source "drivers/scsi/bnx2i/Kconfig"
source "drivers/scsi/be2iscsi/Kconfig"

config SGIWD93_SCSI
tristate "SGI WD93C93 SCSI Driver"
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ obj-$(CONFIG_SCSI_MVSAS) += mvsas/
obj-$(CONFIG_PS3_ROM) += ps3rom.o
obj-$(CONFIG_SCSI_CXGB3_ISCSI) += libiscsi.o libiscsi_tcp.o cxgb3i/
obj-$(CONFIG_SCSI_BNX2_ISCSI) += libiscsi.o bnx2i/
obj-$(CONFIG_BE2ISCSI) += libiscsi.o be2iscsi/
obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o

obj-$(CONFIG_ARM) += arm/
Expand Down
8 changes: 8 additions & 0 deletions drivers/scsi/be2iscsi/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
config BE2ISCSI
tristate "ServerEngines' 10Gbps iSCSI - BladeEngine 2"
depends on PCI && SCSI
select SCSI_ISCSI_ATTRS

help
This driver implements the iSCSI functionality for ServerEngines'
10Gbps Storage adapter - BladeEngine 2.
8 changes: 8 additions & 0 deletions drivers/scsi/be2iscsi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Makefile to build the iSCSI driver for ServerEngine's BladeEngine.
#
#

obj-$(CONFIG_BE2ISCSI) += be2iscsi.o

be2iscsi-y := be_iscsi.o be_main.o be_mgmt.o be_cmds.o
183 changes: 183 additions & 0 deletions drivers/scsi/be2iscsi/be.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/**
* Copyright (C) 2005 - 2009 ServerEngines
* 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 version 2
* as published by the Free Software Foundation. The full GNU General
* Public License is included in this distribution in the file called COPYING.
*
* Contact Information:
* [email protected]
*
* ServerEngines
* 209 N. Fair Oaks Ave
* Sunnyvale, CA 94085
*/

#ifndef BEISCSI_H
#define BEISCSI_H

#include <linux/pci.h>
#include <linux/if_vlan.h>

#define FW_VER_LEN 32

struct be_dma_mem {
void *va;
dma_addr_t dma;
u32 size;
};

struct be_queue_info {
struct be_dma_mem dma_mem;
u16 len;
u16 entry_size; /* Size of an element in the queue */
u16 id;
u16 tail, head;
bool created;
atomic_t used; /* Number of valid elements in the queue */
};

static inline u32 MODULO(u16 val, u16 limit)
{
WARN_ON(limit & (limit - 1));
return val & (limit - 1);
}

static inline void index_inc(u16 *index, u16 limit)
{
*index = MODULO((*index + 1), limit);
}

static inline void *queue_head_node(struct be_queue_info *q)
{
return q->dma_mem.va + q->head * q->entry_size;
}

static inline void *queue_tail_node(struct be_queue_info *q)
{
return q->dma_mem.va + q->tail * q->entry_size;
}

static inline void queue_head_inc(struct be_queue_info *q)
{
index_inc(&q->head, q->len);
}

static inline void queue_tail_inc(struct be_queue_info *q)
{
index_inc(&q->tail, q->len);
}

/*ISCSI */

struct be_eq_obj {
struct be_queue_info q;
char desc[32];

/* Adaptive interrupt coalescing (AIC) info */
bool enable_aic;
u16 min_eqd; /* in usecs */
u16 max_eqd; /* in usecs */
u16 cur_eqd; /* in usecs */
};

struct be_mcc_obj {
struct be_queue_info *q;
struct be_queue_info *cq;
};

struct be_ctrl_info {
u8 __iomem *csr;
u8 __iomem *db; /* Door Bell */
u8 __iomem *pcicfg; /* PCI config space */
struct pci_dev *pdev;

/* Mbox used for cmd request/response */
spinlock_t mbox_lock; /* For serializing mbox cmds to BE card */
struct be_dma_mem mbox_mem;
/* Mbox mem is adjusted to align to 16 bytes. The allocated addr
* is stored for freeing purpose */
struct be_dma_mem mbox_mem_alloced;

/* MCC Rings */
struct be_mcc_obj mcc_obj;
spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock;

/* MCC Async callback */
void (*async_cb) (void *adapter, bool link_up);
void *adapter_ctxt;
};

#include "be_cmds.h"

#define PAGE_SHIFT_4K 12
#define PAGE_SIZE_4K (1 << PAGE_SHIFT_4K)

/* Returns number of pages spanned by the data starting at the given addr */
#define PAGES_4K_SPANNED(_address, size) \
((u32)((((size_t)(_address) & (PAGE_SIZE_4K - 1)) + \
(size) + (PAGE_SIZE_4K - 1)) >> PAGE_SHIFT_4K))

/* Byte offset into the page corresponding to given address */
#define OFFSET_IN_PAGE(addr) \
((size_t)(addr) & (PAGE_SIZE_4K-1))

/* Returns bit offset within a DWORD of a bitfield */
#define AMAP_BIT_OFFSET(_struct, field) \
(((size_t)&(((_struct *)0)->field))%32)

/* Returns the bit mask of the field that is NOT shifted into location. */
static inline u32 amap_mask(u32 bitsize)
{
return (bitsize == 32 ? 0xFFFFFFFF : (1 << bitsize) - 1);
}

static inline void amap_set(void *ptr, u32 dw_offset, u32 mask,
u32 offset, u32 value)
{
u32 *dw = (u32 *) ptr + dw_offset;
*dw &= ~(mask << offset);
*dw |= (mask & value) << offset;
}

#define AMAP_SET_BITS(_struct, field, ptr, val) \
amap_set(ptr, \
offsetof(_struct, field)/32, \
amap_mask(sizeof(((_struct *)0)->field)), \
AMAP_BIT_OFFSET(_struct, field), \
val)

static inline u32 amap_get(void *ptr, u32 dw_offset, u32 mask, u32 offset)
{
u32 *dw = ptr;
return mask & (*(dw + dw_offset) >> offset);
}

#define AMAP_GET_BITS(_struct, field, ptr) \
amap_get(ptr, \
offsetof(_struct, field)/32, \
amap_mask(sizeof(((_struct *)0)->field)), \
AMAP_BIT_OFFSET(_struct, field))

#define be_dws_cpu_to_le(wrb, len) swap_dws(wrb, len)
#define be_dws_le_to_cpu(wrb, len) swap_dws(wrb, len)
static inline void swap_dws(void *wrb, int len)
{
#ifdef __BIG_ENDIAN
u32 *dw = wrb;
WARN_ON(len % 4);
do {
*dw = cpu_to_le32(*dw);
dw++;
len -= 4;
} while (len);
#endif /* __BIG_ENDIAN */
}

extern void beiscsi_cq_notify(struct be_ctrl_info *ctrl, u16 qid, bool arm,
u16 num_popped);

#endif /* BEISCSI_H */
Loading

0 comments on commit 6733b39

Please sign in to comment.