[ofa-general] [PATCH 1/6] nes: Cosmetic changes; support virtual WQs and PPC
Glenn Grundstrom NetEffect
glenn at lists.openfabrics.org
Wed Nov 14 14:19:26 PST 2007
Updated code for the NetEffect NE020 adapter.
Updates include:
- Support for userspace/virtual WQs.
- PowerPC
- Support for multiple debugging levels
- Many, many cosmetic changes inline with kernel.org standards
Diffs for Makefile, nes.c and nes.h
Signed-off-by: Glenn Grundstrom <ggrundstrom at neteffect.com>
---
diff --git a/drivers/infiniband/hw/nes/Kconfig b/drivers/infiniband/hw/nes/Kconfig
diff --git a/drivers/infiniband/hw/nes/Makefile b/drivers/infiniband/hw/nes/Makefile
index 6e94d56..3514851 100644
--- a/drivers/infiniband/hw/nes/Makefile
+++ b/drivers/infiniband/hw/nes/Makefile
@@ -1,7 +1,3 @@
-
-EXTRA_CFLAGS += -DNES_MINICM
-
obj-$(CONFIG_INFINIBAND_NES) += iw_nes.o
iw_nes-objs := nes.o nes_hw.o nes_nic.o nes_utils.o nes_verbs.o nes_cm.o
-
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index ecf60a6..4f7ae5c 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -43,6 +43,7 @@
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/if_arp.h>
+#include <linux/highmem.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/byteorder.h>
@@ -70,12 +71,8 @@ MODULE_VERSION(DRV_VERSION);
int max_mtu = 9000;
int nics_per_function = 1;
-
-#ifdef NES_INT_MODERATE
-int interrupt_mod_interval = 128;
-#else
int interrupt_mod_interval = 0;
-#endif
+
/* Interoperability */
int mpa_version = 1;
@@ -96,9 +93,9 @@ unsigned int nes_drv_opt = 0;
module_param(nes_drv_opt, int, 0);
MODULE_PARM_DESC(nes_drv_opt, "Driver option parameters");
-unsigned int nes_debug_level = 0xffffffff;
-module_param(nes_debug_level, uint, 0644);
-MODULE_PARM_DESC(nes_debug_level, "Enable debug output level");
+unsigned int nes_debug_level = 0x0;
+module_param_named(debug_level, nes_debug_level, uint, 0644);
+MODULE_PARM_DESC(debug_level, "Enable debug output level");
LIST_HEAD(nes_adapter_list);
LIST_HEAD(nes_dev_list);
@@ -127,7 +124,7 @@ MODULE_DEVICE_TABLE(pci, nes_pci_table);
static int nes_inetaddr_event(struct notifier_block *, unsigned long, void *);
static int nes_net_event(struct notifier_block *, unsigned long, void *);
-static int notifiers_registered = 0;
+static int nes_notifiers_registered = 0;
static struct notifier_block nes_inetaddr_notifier = {
@@ -165,7 +162,7 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
netdev = nesdev->netdev[0];
nesvnic = netdev_priv(netdev);
if (netdev == event_netdev) {
- if (0 == nesvnic->rdma_enabled) {
+ if (nesvnic->rdma_enabled == 0) {
nes_debug(NES_DBG_NETDEV, "Returning without processing event for %s since"
" RDMA is not enabled.\n",
netdev->name);
@@ -224,7 +221,7 @@ static int nes_net_event(struct notifier_block *notifier,
netdev = nesdev->netdev[0];
nesvnic = netdev_priv(netdev);
if (netdev == neigh->dev) {
- if (0 == nesvnic->rdma_enabled) {
+ if (nesvnic->rdma_enabled == 0) {
nes_debug(NES_DBG_NETDEV, "Skipping device %s since no RDMA\n",
netdev->name);
} else {
@@ -268,6 +265,7 @@ void nes_add_ref(struct ib_qp *ibqp)
*/
void nes_rem_ref(struct ib_qp *ibqp)
{
+ unsigned long flags;
u64 u64temp;
struct nes_qp *nesqp;
struct nes_vnic *nesvnic = to_nesvnic(ibqp->device);
@@ -288,15 +286,28 @@ void nes_rem_ref(struct ib_qp *ibqp)
atomic_inc(&qps_destroyed);
/* Free the control structures */
- pci_free_consistent(nesdev->pcidev, nesqp->qp_mem_size, nesqp->hwqp.sq_vbase,
- nesqp->hwqp.sq_pbase);
+
+ if (nesqp->pbl_vbase) {
+ pci_free_consistent(nesdev->pcidev, nesqp->qp_mem_size,
+ nesqp->hwqp.q2_vbase, nesqp->hwqp.q2_pbase);
+ spin_lock_irqsave(&nesadapter->pbl_lock, flags);
+ nesadapter->free_256pbl++;
+ spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
+ pci_free_consistent(nesdev->pcidev, 256, nesqp->pbl_vbase, nesqp->pbl_pbase);
+ nesqp->pbl_vbase = NULL;
+ kunmap(nesqp->page);
+
+ } else {
+ pci_free_consistent(nesdev->pcidev, nesqp->qp_mem_size,
+ nesqp->hwqp.sq_vbase, nesqp->hwqp.sq_pbase);
+ }
nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = NULL;
nes_free_resource(nesadapter, nesadapter->allocated_qps, nesqp->hwqp.qp_id);
/* Destroy the QP */
- cqp_request = nes_get_cqp_request(nesdev, NES_CQP_REQUEST_NOT_HOLDING_LOCK);
- if (NULL == cqp_request) {
+ cqp_request = nes_get_cqp_request(nesdev);
+ if (cqp_request == NULL) {
nes_debug(NES_DBG_QP, "Failed to get a cqp_request.\n");
return;
}
@@ -307,7 +318,7 @@ void nes_rem_ref(struct ib_qp *ibqp)
cpu_to_le32(NES_CQP_DESTROY_QP | NES_CQP_QP_TYPE_IWARP);
if (nesqp->hte_added) {
- cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] |= cpu_to_le32(NES_CQP_QP_DEL_HTE);
+ cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] |= cpu_to_le32(NES_CQP_QP_DEL_HTE);
nesqp->hte_added = 0;
}
@@ -323,8 +334,7 @@ void nes_rem_ref(struct ib_qp *ibqp)
cqp_wqe->wqe_words[NES_CQP_QP_WQE_CONTEXT_HIGH_IDX] =
cpu_to_le32((u32)(u64temp >> 32));
- nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_NOT_HOLDING_LOCK,
- NES_CQP_REQUEST_RING_DOORBELL);
+ nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL);
kfree(nesqp->allocated_buffer);
}
@@ -397,7 +407,7 @@ static irqreturn_t nes_interrupt(int irq, void *dev_id)
}
}
if ((((int_stat & int_req) & NES_INT_INTF) == NES_INT_INTF) &&
- (0 == handled)) {
+ (handled == 0)) {
intf_int_stat = nes_read32(nesdev->regs+NES_INTF_INT_STAT);
if ((intf_int_stat & nesdev->intf_int_req) != 0) {
handled = 1;
@@ -420,7 +430,7 @@ static irqreturn_t nes_interrupt(int irq, void *dev_id)
if (handled) {
#ifdef NES_NAPI
- if (0 == nes_napi_isr(nesdev)) {
+ if (nes_napi_isr(nesdev) == 0) {
#endif
tasklet_schedule(&nesdev->dpc_tasklet);
#ifdef NES_NAPI
@@ -506,14 +516,13 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
pci_set_master(pcidev);
/* Allocate hardware structure */
- nesdev = kmalloc(sizeof(struct nes_device), GFP_KERNEL);
+ nesdev = kzalloc(sizeof(struct nes_device), GFP_KERNEL);
if (!nesdev) {
printk(KERN_ERR PFX "%s: Unable to alloc hardware struct\n", pci_name(pcidev));
ret = -ENOMEM;
goto bail2;
}
- memset(nesdev, 0, sizeof(struct nes_device));
nes_debug(NES_DBG_INIT, "Allocated nes device at %p\n", nesdev);
nesdev->pcidev = pcidev;
pci_set_drvdata(pcidev, nesdev);
@@ -536,7 +545,6 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
/* Ensure interrupts are disabled */
nes_write32(nesdev->regs+NES_INT_MASK, 0x7fffffff);
-#ifdef CONFIG_PCI_MSI
if (nes_drv_opt & NES_DRV_OPT_ENABLE_MSI) {
if (!pci_enable_msi(nesdev->pcidev)) {
nesdev->msi_enabled = 1;
@@ -550,24 +558,25 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
nes_debug(NES_DBG_INIT, "MSI not requested due to driver options for device %s\n",
pci_name(pcidev));
}
-#else
- nes_debug(NES_DBG_INIT, "MSI not supported by this kernel for device %s\n",
- pci_name(pcidev));
-#endif
- nesdev->et_rx_coalesce_usecs_irq = interrupt_mod_interval;
nesdev->csr_start = pci_resource_start(nesdev->pcidev, BAR_0);
- nesdev->doorbell_start = pci_resource_start(nesdev->pcidev, BAR_1);
+ nesdev->doorbell_region = pci_resource_start(nesdev->pcidev, BAR_1);
/* Init the adapter */
nesdev->nesadapter = nes_init_adapter(nesdev, hw_rev);
+ nesdev->nesadapter->et_rx_coalesce_usecs_irq = interrupt_mod_interval;
if (!nesdev->nesadapter) {
printk(KERN_ERR PFX "Unable to initialize adapter.\n" );
ret = -ENOMEM;
goto bail5;
}
- nesdev->mac_index = PCI_FUNC(nesdev->pcidev->devfn)%nesdev->nesadapter->port_count;
+ /* nesdev->base_doorbell_index =
+ nesdev->nesadapter->pd_config_base[PCI_FUNC(nesdev->pcidev->devfn)]; */
+ nesdev->base_doorbell_index = 1;
+ nesdev->doorbell_start = nesdev->nesadapter->doorbell_start;
+ nesdev->mac_index = PCI_FUNC(nesdev->pcidev->devfn) % nesdev->nesadapter->port_count;
+
tasklet_init(&nesdev->dpc_tasklet, nes_dpc, (unsigned long)nesdev);
/* bring up the Control QP */
@@ -589,7 +598,7 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
}
/* TODO: This really should be the first driver to load, not function 0 */
- if (0 == PCI_FUNC(nesdev->pcidev->devfn)) {
+ if (PCI_FUNC(nesdev->pcidev->devfn) == 0) {
/* pick up PCI and critical errors if the first driver to load */
nesdev->intf_int_req = NES_INTF_INT_PCIERR | NES_INTF_INT_CRITERR;
nesdev->int_req |= NES_INT_INTF;
@@ -616,11 +625,7 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
list_add_tail(&nesdev->list, &nes_dev_list);
/* Request an interrupt line for the driver */
-#ifdef IRQF_SHARED
ret = request_irq(pcidev->irq, nes_interrupt, IRQF_SHARED, DRV_NAME, nesdev);
-#else
- ret = request_irq(pcidev->irq, nes_interrupt, SA_SHIRQ, DRV_NAME, nesdev);
-#endif
if (ret) {
printk(KERN_ERR PFX "%s: requested IRQ %u is busy\n",
pci_name(pcidev), pcidev->irq);
@@ -629,11 +634,11 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req);
- if (!notifiers_registered) {
+ if (nes_notifiers_registered == 0) {
register_inetaddr_notifier(&nes_inetaddr_notifier);
register_netevent_notifier(&nes_net_notifier);
- notifiers_registered = 1;
}
+ nes_notifiers_registered++;
/* Initialize network devices */
if ((netdev = nes_netdev_init(nesdev, mmio_regs)) == NULL) {
@@ -673,10 +678,10 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
nes_debug(NES_DBG_INIT, "netdev_count=%d, nesadapter->netdev_count=%d\n",
nesdev->netdev_count, nesdev->nesadapter->netdev_count);
- if (notifiers_registered) {
+ nes_notifiers_registered--;
+ if (nes_notifiers_registered == 0) {
unregister_netevent_notifier(&nes_net_notifier);
unregister_inetaddr_notifier(&nes_inetaddr_notifier);
- notifiers_registered = 0;
}
list_del(&nesdev->list);
@@ -685,11 +690,9 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
bail65:
printk(KERN_ERR PFX "bail65\n");
free_irq(pcidev->irq, nesdev);
-#ifdef CONFIG_PCI_MSI
if (nesdev->msi_enabled) {
pci_disable_msi(pcidev);
}
-#endif
bail6:
printk(KERN_ERR PFX "bail6\n");
tasklet_kill(&nesdev->dpc_tasklet);
@@ -722,9 +725,7 @@ static void __devexit nes_remove(struct pci_dev *pcidev)
{
struct nes_device *nesdev = pci_get_drvdata(pcidev);
struct net_device *netdev;
- int netdev_index=0;
-
- nes_debug(NES_DBG_SHUTDOWN, "called.\n");
+ int netdev_index = 0;
if (nesdev->netdev_count) {
netdev = nesdev->netdev[netdev_index];
@@ -738,10 +739,11 @@ static void __devexit nes_remove(struct pci_dev *pcidev)
nesdev->nesadapter->netdev_count--;
}
}
- if (notifiers_registered) {
+
+ nes_notifiers_registered--;
+ if (nes_notifiers_registered == 0) {
unregister_netevent_notifier(&nes_net_notifier);
unregister_inetaddr_notifier(&nes_inetaddr_notifier);
- notifiers_registered = 0;
}
list_del(&nesdev->list);
@@ -753,11 +755,9 @@ static void __devexit nes_remove(struct pci_dev *pcidev)
free_irq(pcidev->irq, nesdev);
-#ifdef CONFIG_PCI_MSI
if (nesdev->msi_enabled) {
pci_disable_msi(pcidev);
}
-#endif
iounmap(nesdev->regs);
kfree(nesdev);
@@ -788,11 +788,7 @@ static int __init nes_init_module(void)
printk(KERN_ERR PFX "Unable to start NetEffect iWARP CM.\n");
return retval;
}
-#ifdef OFED_1_2
- return(pci_module_init(&nes_pci_driver));
-#else
- return(pci_register_driver(&nes_pci_driver));
-#endif
+ return pci_register_driver(&nes_pci_driver);
}
@@ -808,4 +804,3 @@ static void __exit nes_exit_module(void)
module_init(nes_init_module);
module_exit(nes_exit_module);
-
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 96dfadd..48082ed 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -46,6 +46,7 @@
#include <asm/semaphore.h>
#include <linux/version.h>
#include <asm/io.h>
+#include <linux/crc32c.h>
#include <rdma/ib_smi.h>
#include <rdma/ib_verbs.h>
@@ -53,106 +54,109 @@
#include <rdma/rdma_cm.h>
#include <rdma/iw_cm.h>
-#define TBIRD
-#define NES_TWO_PORT
-#define NES_ENABLE_CQE_READ
#define NES_SEND_FIRST_WRITE
#define QUEUE_DISCONNECTS
-#define DRV_BUILD "1"
+#define DRV_BUILD "1"
#define DRV_NAME "iw_nes"
-#define DRV_VERSION "0.5 Build " DRV_BUILD
+#define DRV_VERSION "0.6 Build " DRV_BUILD
#define PFX DRV_NAME ": "
/*
* NetEffect PCI vendor id and NE010 PCI device id.
*/
#ifndef PCI_VENDOR_ID_NETEFFECT /* not in pci.ids yet */
-#define PCI_VENDOR_ID_NETEFFECT 0x1678
+#define PCI_VENDOR_ID_NETEFFECT 0x1678
#define PCI_DEVICE_ID_NETEFFECT_NE020 0x0100
#endif
-#define NE020_REV 4
-#define NE020_REV1 5
+#define NE020_REV 4
+#define NE020_REV1 5
-#define BAR_0 0
-#define BAR_1 2
+#define BAR_0 0
+#define BAR_1 2
-#define RX_BUF_SIZE (1536 + 8)
+#define RX_BUF_SIZE (1536 + 8)
+#define NES_REG0_SIZE (4 * 1024)
+#define NES_TX_TIMEOUT (6*HZ)
+#define NES_FIRST_QPN 64
+#define NES_SW_CONTEXT_ALIGN 1024
-#define NES_REG0_SIZE (4 * 1024)
-#define NES_TX_TIMEOUT (6*HZ)
-#define NES_FIRST_QPN 64
-#define NES_SW_CONTEXT_ALIGN 1024
+#define NES_NIC_MAX_NICS 16
+#define NES_MAX_ARP_TABLE_SIZE 4096
-#define NES_NIC_MAX_NICS 16
-#define NES_MAX_ARP_TABLE_SIZE 4096
+#define NES_NIC_CEQ_SIZE 8
+/* NICs will be on a separate CQ */
+#define NES_CCEQ_SIZE ((nesadapter->max_cq / nesadapter->port_count) - 32)
-#define MAX_DPC_ITERATIONS 128
+#define NES_MAX_PORT_COUNT 4
-#define NES_DRV_OPT_ENABLE_MPA_VER_0 0x00000001
-#define NES_DRV_OPT_DISABLE_MPA_CRC 0x00000002
-#define NES_DRV_OPT_DISABLE_FIRST_WRITE 0x00000004
-#define NES_DRV_OPT_DISABLE_INTF 0x00000008
-#define NES_DRV_OPT_ENABLE_MSI 0x00000010
-#define NES_DRV_OPT_DUAL_LOGICAL_PORT 0x00000020
-#define NES_DRV_OPT_SUPRESS_OPTION_BC 0x00000040
-#define NES_DRV_OPT_NO_INLINE_DATA 0x00000080
+#define MAX_DPC_ITERATIONS 128
-#define NES_AEQ_EVENT_TIMEOUT 2500
-#define NES_DISCONNECT_EVENT_TIMEOUT 2000
+#define NES_CQP_REQUEST_NO_DOORBELL_RING 0
+#define NES_CQP_REQUEST_RING_DOORBELL 1
+
+#define NES_DRV_OPT_ENABLE_MPA_VER_0 0x00000001
+#define NES_DRV_OPT_DISABLE_MPA_CRC 0x00000002
+#define NES_DRV_OPT_DISABLE_FIRST_WRITE 0x00000004
+#define NES_DRV_OPT_DISABLE_INTF 0x00000008
+#define NES_DRV_OPT_ENABLE_MSI 0x00000010
+#define NES_DRV_OPT_DUAL_LOGICAL_PORT 0x00000020
+#define NES_DRV_OPT_SUPRESS_OPTION_BC 0x00000040
+#define NES_DRV_OPT_NO_INLINE_DATA 0x00000080
+#define NES_DRV_OPT_DISABLE_INT_MOD 0x00000100
+#define NES_DRV_OPT_DISABLE_VIRT_WQ 0x00000200
+
+#define NES_AEQ_EVENT_TIMEOUT 2500
+#define NES_DISCONNECT_EVENT_TIMEOUT 2000
/* debug levels */
-#define NES_DBG_HW 0x00000001
-#define NES_DBG_INIT 0x00000002
-#define NES_DBG_ISR 0x00000004
-#define NES_DBG_PHY 0x00000008
-#define NES_DBG_NETDEV 0x00000010
-#define NES_DBG_CM 0x00000020
+/* must match userspace */
+#define NES_DBG_HW 0x00000001
+#define NES_DBG_INIT 0x00000002
+#define NES_DBG_ISR 0x00000004
+#define NES_DBG_PHY 0x00000008
+#define NES_DBG_NETDEV 0x00000010
+#define NES_DBG_CM 0x00000020
#define NES_DBG_CM1 0x00000040
-#define NES_DBG_NIC_RX 0x00000080
-#define NES_DBG_NIC_TX 0x00000100
-#define NES_DBG_CQP 0x00000200
-#define NES_DBG_MMAP 0x00000400
-#define NES_DBG_MR 0x00000800
-#define NES_DBG_PD 0x00001000
-#define NES_DBG_CQ 0x00002000
-#define NES_DBG_QP 0x00004000
-#define NES_DBG_MOD_QP 0x00008000
-#define NES_DBG_AEQ 0x00010000
-#define NES_DBG_IW_RX 0x00020000
-#define NES_DBG_IW_TX 0x00040000
-#define NES_DBG_SHUTDOWN 0x00080000
-#define NES_DBG_RSVD1 0x10000000
-#define NES_DBG_RSVD2 0x20000000
-#define NES_DBG_RSVD3 0x40000000
-#define NES_DBG_RSVD4 0x80000000
-#define NES_DBG_ALL 0xffffffff
+#define NES_DBG_NIC_RX 0x00000080
+#define NES_DBG_NIC_TX 0x00000100
+#define NES_DBG_CQP 0x00000200
+#define NES_DBG_MMAP 0x00000400
+#define NES_DBG_MR 0x00000800
+#define NES_DBG_PD 0x00001000
+#define NES_DBG_CQ 0x00002000
+#define NES_DBG_QP 0x00004000
+#define NES_DBG_MOD_QP 0x00008000
+#define NES_DBG_AEQ 0x00010000
+#define NES_DBG_IW_RX 0x00020000
+#define NES_DBG_IW_TX 0x00040000
+#define NES_DBG_SHUTDOWN 0x00080000
+#define NES_DBG_RSVD1 0x10000000
+#define NES_DBG_RSVD2 0x20000000
+#define NES_DBG_RSVD3 0x40000000
+#define NES_DBG_RSVD4 0x80000000
+#define NES_DBG_ALL 0xffffffff
#ifdef CONFIG_INFINIBAND_NES_DEBUG
-#define assert(expr) \
-if(!(expr)) { \
- printk(KERN_ERR PFX "Assertion failed! %s, %s, %s, line %d\n", \
- #expr, __FILE__, __FUNCTION__, __LINE__); \
-}
-
#define nes_debug(level, fmt, args...) \
if (level & nes_debug_level) \
printk(KERN_ERR PFX "%s[%u]: " fmt, __FUNCTION__, __LINE__, ##args)
-#ifndef dprintk
-#define dprintk(fmt, args...) do { printk(KERN_ERR PFX fmt, ##args); } while (0)
-#endif
-#define NES_EVENT_TIMEOUT 1200000
-/* #define NES_EVENT_TIMEOUT 1200 */
+#define assert(expr) \
+if(!(expr)) { \
+ printk(KERN_ERR PFX "Assertion failed! %s, %s, %s, line %d\n", \
+ #expr, __FILE__, __FUNCTION__, __LINE__); \
+}
+
+#define NES_EVENT_TIMEOUT 1200000
#else
-#define assert(expr) do {} while (0)
#define nes_debug(level, fmt, args...)
-#define dprintk(fmt, args...) do {} while (0)
+#define assert(expr) do {} while (0)
-#define NES_EVENT_TIMEOUT 100000
+#define NES_EVENT_TIMEOUT 100000
#endif
#include "nes_hw.h"
@@ -205,6 +209,14 @@ extern atomic_t cm_accel_dropped_pkts;
extern atomic_t cm_resets_recvd;
extern u32 crit_err_count;
+extern u32 int_mod_timer_init;
+extern u32 int_mod_cq_depth_256;
+extern u32 int_mod_cq_depth_128;
+extern u32 int_mod_cq_depth_32;
+extern u32 int_mod_cq_depth_24;
+extern u32 int_mod_cq_depth_16;
+extern u32 int_mod_cq_depth_4;
+extern u32 int_mod_cq_depth_1;
extern u32 mh_detected;
extern u32 mh_pauses_sent;
@@ -217,67 +229,60 @@ extern atomic_t cqp_reqs_redriven;
struct nes_device {
- struct nes_adapter *nesadapter;
- void __iomem *regs;
- void __iomem *index_reg;
- struct pci_dev *pcidev;
- struct net_device *netdev[NES_NIC_MAX_NICS];
- u64 link_status_interrupts;
- struct tasklet_struct dpc_tasklet;
- spinlock_t indexed_regs_lock;
- unsigned long doorbell_start;
- unsigned long csr_start;
- unsigned long mac_tx_errors;
- unsigned long mac_pause_frames_sent;
- unsigned long mac_pause_frames_received;
- unsigned long mac_rx_errors;
- unsigned long mac_rx_crc_errors;
- unsigned long mac_rx_symbol_err_frames;
- unsigned long mac_rx_jabber_frames;
- unsigned long mac_rx_oversized_frames;
- unsigned long mac_rx_short_frames;
- unsigned int mac_index;
- unsigned int nes_stack_start;
+ struct nes_adapter *nesadapter;
+ void __iomem *regs;
+ void __iomem *index_reg;
+ struct pci_dev *pcidev;
+ struct net_device *netdev[NES_NIC_MAX_NICS];
+ u64 link_status_interrupts;
+ struct tasklet_struct dpc_tasklet;
+ spinlock_t indexed_regs_lock;
+ unsigned long csr_start;
+ unsigned long doorbell_region;
+ unsigned long doorbell_start;
+ unsigned long mac_tx_errors;
+ unsigned long mac_pause_frames_sent;
+ unsigned long mac_pause_frames_received;
+ unsigned long mac_rx_errors;
+ unsigned long mac_rx_crc_errors;
+ unsigned long mac_rx_symbol_err_frames;
+ unsigned long mac_rx_jabber_frames;
+ unsigned long mac_rx_oversized_frames;
+ unsigned long mac_rx_short_frames;
+ unsigned int mac_index;
+ unsigned int nes_stack_start;
/* Control Structures */
- void *cqp_vbase;
- dma_addr_t cqp_pbase;
- u32 cqp_mem_size;
- u8 ceq_index;
- u8 nic_ceq_index;
- struct nes_hw_cqp cqp;
- struct nes_hw_cq ccq;
- struct list_head cqp_avail_reqs;
- struct list_head cqp_pending_reqs;
+ void *cqp_vbase;
+ dma_addr_t cqp_pbase;
+ u32 cqp_mem_size;
+ u8 ceq_index;
+ u8 nic_ceq_index;
+ struct nes_hw_cqp cqp;
+ struct nes_hw_cq ccq;
+ struct list_head cqp_avail_reqs;
+ struct list_head cqp_pending_reqs;
struct nes_cqp_request *nes_cqp_requests;
- u32 int_req;
- u32 int_stat;
- u32 timer_int_req;
- u32 timer_only_int_count;
- u32 intf_int_req;
- u32 et_rx_coalesce_usecs_irq;
- u32 last_mac_tx_pauses;
- u32 last_used_chunks_tx;
- struct list_head list;
-
- u16 base_doorbell_index;
- u8 msi_enabled;
- u8 netdev_count;
- u8 napi_isr_ran;
- u8 disable_rx_flow_control;
- u8 disable_tx_flow_control;
+ u32 int_req;
+ u32 int_stat;
+ u32 timer_int_req;
+ u32 timer_only_int_count;
+ u32 intf_int_req;
+ u32 last_mac_tx_pauses;
+ u32 last_used_chunks_tx;
+ struct list_head list;
+
+ u16 base_doorbell_index;
+ u16 deepcq_count;
+ u8 msi_enabled;
+ u8 netdev_count;
+ u8 napi_isr_ran;
+ u8 disable_rx_flow_control;
+ u8 disable_tx_flow_control;
};
-static inline int nes_skb_is_gso(const struct sk_buff *skb)
-{
- return skb_shinfo(skb)->gso_size;
-}
-
-#define nes_skb_linearize(_skb) skb_linearize(_skb)
-
-
/* Read from memory-mapped device */
static inline u32 nes_read_indexed(struct nes_device *nesdev, u32 reg_index)
{
@@ -358,8 +363,6 @@ static inline int nes_alloc_resource(struct nes_adapter *nesadapter,
return -EMFILE;
}
}
- nes_debug(NES_DBG_HW, "find_next_zero_bit returned = %u (max = %u).\n",
- resource_num, max_resources);
set_bit(resource_num, resource_array);
*next = resource_num+1;
if (*next == max_resources) {
@@ -397,151 +400,52 @@ static inline void nes_free_resource(struct nes_adapter *nesadapter,
spin_unlock_irqrestore(&nesadapter->resource_lock, flags);
}
-static inline struct nes_vnic *to_nesvnic(struct ib_device *ibdev) {
- return(container_of(ibdev, struct nes_ib_device, ibdev)->nesvnic);
-}
-
-static inline struct nes_pd *to_nespd(struct ib_pd *ibpd) {
- return(container_of(ibpd, struct nes_pd, ibpd));
-}
-
-static inline struct nes_ucontext *to_nesucontext(struct ib_ucontext *ibucontext) {
- return(container_of(ibucontext, struct nes_ucontext, ibucontext));
+static inline struct nes_vnic *to_nesvnic(struct ib_device *ibdev)
+{
+ return container_of(ibdev, struct nes_ib_device, ibdev)->nesvnic;
}
-static inline struct nes_mr *to_nesmr(struct ib_mr *ibmr) {
- return(container_of(ibmr, struct nes_mr, ibmr));
+static inline struct nes_pd *to_nespd(struct ib_pd *ibpd)
+{
+ return container_of(ibpd, struct nes_pd, ibpd);
}
-static inline struct nes_mr *to_nesmr_from_ibfmr(struct ib_fmr *ibfmr) {
- return(container_of(ibfmr, struct nes_mr, ibfmr));
+static inline struct nes_ucontext *to_nesucontext(struct ib_ucontext *ibucontext)
+{
+ return container_of(ibucontext, struct nes_ucontext, ibucontext);
}
-static inline struct nes_mr *to_nesmw(struct ib_mw *ibmw) {
- return(container_of(ibmw, struct nes_mr, ibmw));
+static inline struct nes_mr *to_nesmr(struct ib_mr *ibmr)
+{
+ return container_of(ibmr, struct nes_mr, ibmr);
}
-static inline struct nes_fmr *to_nesfmr(struct nes_mr *nesmr) {
- return(container_of(nesmr, struct nes_fmr, nesmr));
+static inline struct nes_mr *to_nesmr_from_ibfmr(struct ib_fmr *ibfmr)
+{
+ return container_of(ibfmr, struct nes_mr, ibfmr);
}
-static inline struct nes_cq *to_nescq(struct ib_cq *ibcq) {
- return(container_of(ibcq, struct nes_cq, ibcq));
+static inline struct nes_mr *to_nesmw(struct ib_mw *ibmw)
+{
+ return container_of(ibmw, struct nes_mr, ibmw);
}
-static inline struct nes_qp *to_nesqp(struct ib_qp *ibqp) {
- return(container_of(ibqp, struct nes_qp, ibqp));
+static inline struct nes_fmr *to_nesfmr(struct nes_mr *nesmr)
+{
+ return container_of(nesmr, struct nes_fmr, nesmr);
}
-
-#define NES_CQP_REQUEST_NOT_HOLDING_LOCK 0
-#define NES_CQP_REQUEST_HOLDING_LOCK 1
-#define NES_CQP_REQUEST_NO_DOORBELL_RING 0
-#define NES_CQP_REQUEST_RING_DOORBELL 1
-
-static inline struct nes_cqp_request
- *nes_get_cqp_request(struct nes_device *nesdev, int holding_lock) {
- unsigned long flags;
- struct nes_cqp_request *cqp_request = NULL;
-
- if (!holding_lock) {
- spin_lock_irqsave(&nesdev->cqp.lock, flags);
- }
- if (!list_empty(&nesdev->cqp_avail_reqs)) {
- cqp_request = list_entry(nesdev->cqp_avail_reqs.next,
- struct nes_cqp_request, list);
- atomic_inc(&cqp_reqs_allocated);
- list_del_init(&cqp_request->list);
- } else if (!holding_lock) {
- spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
- cqp_request = kzalloc(sizeof(struct nes_cqp_request),
- GFP_KERNEL);
- if (cqp_request) {
- cqp_request->dynamic = 1;
- INIT_LIST_HEAD(&cqp_request->list);
- atomic_inc(&cqp_reqs_dynallocated);
- }
- spin_lock_irqsave(&nesdev->cqp.lock, flags);
- }
- if (!holding_lock) {
- spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
- }
-
- if (cqp_request) {
- init_waitqueue_head(&cqp_request->waitq);
- cqp_request->waiting = 0;
- cqp_request->request_done = 0;
- init_waitqueue_head(&cqp_request->waitq);
- nes_debug(NES_DBG_CQP, "Got cqp request %p from the available list \n",
- cqp_request);
- } else
- printk(KERN_ERR PFX "%s: Could not allocated a CQP request.\n",
- __FUNCTION__);
-
- return cqp_request;
+static inline struct nes_cq *to_nescq(struct ib_cq *ibcq)
+{
+ return container_of(ibcq, struct nes_cq, ibcq);
}
-static inline void nes_post_cqp_request(struct nes_device *nesdev,
- struct nes_cqp_request *cqp_request, int holding_lock, int ring_doorbell)
+static inline struct nes_qp *to_nesqp(struct ib_qp *ibqp)
{
- /* caller must be holding CQP lock */
- struct nes_hw_cqp_wqe *cqp_wqe;
- unsigned long flags;
- u32 cqp_head;
-
- if (!holding_lock) {
- spin_lock_irqsave(&nesdev->cqp.lock, flags);
- }
-
- if (((((nesdev->cqp.sq_tail+(nesdev->cqp.sq_size*2))-nesdev->cqp.sq_head) &
- (nesdev->cqp.sq_size - 1)) != 1)
- && (list_empty(&nesdev->cqp_pending_reqs))) {
- cqp_head = nesdev->cqp.sq_head++;
- nesdev->cqp.sq_head &= nesdev->cqp.sq_size-1;
- cqp_wqe = &nesdev->cqp.sq_vbase[cqp_head];
- memcpy(cqp_wqe, &cqp_request->cqp_wqe, sizeof(*cqp_wqe));
- barrier();
- cqp_wqe->wqe_words[NES_CQP_WQE_COMP_SCRATCH_LOW_IDX] = cpu_to_le32((u32)((u64)(cqp_request)));
- cqp_wqe->wqe_words[NES_CQP_WQE_COMP_SCRATCH_HIGH_IDX] = cpu_to_le32((u32)(((u64)(cqp_request))>>32));
- nes_debug(NES_DBG_CQP, "CQP request (opcode 0x%02X), line 1 = 0x%08X put on CQPs SQ,"
- " request = %p, cqp_head = %u, cqp_tail = %u, cqp_size = %u,"
- " waiting = %d, refcount = %d.\n",
- le32_to_cpu(cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX])&0x3f,
- le32_to_cpu(cqp_wqe->wqe_words[NES_CQP_WQE_ID_IDX]), cqp_request,
- nesdev->cqp.sq_head, nesdev->cqp.sq_tail, nesdev->cqp.sq_size,
- cqp_request->waiting, atomic_read(&cqp_request->refcount));
- barrier();
- if (ring_doorbell) {
- /* Ring doorbell (1 WQEs) */
- nes_write32(nesdev->regs+NES_WQE_ALLOC, 0x01800000 | nesdev->cqp.qp_id);
- }
-
- barrier();
- } else {
- atomic_inc(&cqp_reqs_queued);
- nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X), line 1 = 0x%08X"
- " put on the pending queue.\n",
- cqp_request,
- cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX]&0x3f,
- cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_ID_IDX]);
- list_add_tail(&cqp_request->list, &nesdev->cqp_pending_reqs);
- }
-
- if (!holding_lock) {
- spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
- }
-
- return;
+ return container_of(ibqp, struct nes_qp, ibqp);
}
-/* Utils */
-#define CRC32C_POLY 0x1EDC6F41
-#define ORDER 32
-#define REFIN 1
-#define REFOUT 1
-#define NES_HASH_CRC_INITAL_VALUE 0xFFFFFFFF
-#define NES_HASH_CRC_FINAL_XOR 0xFFFFFFFF
/* nes.c */
void nes_add_ref(struct ib_qp *);
@@ -550,6 +454,7 @@ struct ib_qp *nes_get_qp(struct ib_device *, int);
/* nes_hw.c */
struct nes_adapter *nes_init_adapter(struct nes_device *, u8);
+void nes_nic_init_timer_defaults(struct nes_device *, u8 );
unsigned int nes_reset_adapter_ne020(struct nes_device *, u8 *);
int nes_init_serdes(struct nes_device *, u8, u8, u8);
void nes_init_csr_ne020(struct nes_device *, u8, u8);
@@ -572,6 +477,7 @@ int nes_destroy_cqp(struct nes_device *);
int nes_nic_cm_xmit(struct sk_buff *, struct net_device *);
/* nes_nic.c */
+void nes_netdev_set_multicast_list(struct net_device *);
void nes_netdev_exit(struct nes_vnic *);
struct net_device *nes_netdev_init(struct nes_device *, void __iomem *);
void nes_netdev_destroy(struct net_device *);
@@ -584,10 +490,8 @@ void nes_update_arp(unsigned char *, u32, u32, u16, u16);
void nes_manage_arp_cache(struct net_device *, unsigned char *, u32, u32);
void nes_sock_release(struct nes_qp *, unsigned long *);
struct nes_cm_core *nes_cm_alloc_core(void);
-void nes_disconnect_worker(void *);
void flush_wqes(struct nes_device *nesdev, struct nes_qp *, u32, u32);
int nes_manage_apbvt(struct nes_vnic *, u32, u32, u32);
-
int nes_cm_disconn(struct nes_qp *);
void nes_cm_disconn_worker(void *);
@@ -605,6 +509,8 @@ void nes_write_1G_phy_reg(struct nes_device *, u8, u8, u16);
void nes_read_1G_phy_reg(struct nes_device *, u8, u8, u16 *);
void nes_write_10G_phy_reg(struct nes_device *, u16, u8, u16);
void nes_read_10G_phy_reg(struct nes_device *, u16, u8);
+struct nes_cqp_request *nes_get_cqp_request(struct nes_device *);
+void nes_post_cqp_request(struct nes_device *, struct nes_cqp_request *, int);
int nes_arp_table(struct nes_device *, u32, u8 *, u32);
void nes_mh_fix(unsigned long);
void nes_dump_mem(unsigned int, void *, int);
More information about the general
mailing list