[PATCH 2/2] be2net: Added functionality to support RoCE driver

2012-03-26 Thread Parav Pandit
From: Parav Pandit 

- Increased MSIX vectors by 5 for RoCE traffic.
- Added macro to check roce support on a device.
- Added device specific doorbell, msix vector fields shared with nic 
functionality.
- Provides RoCE driver registration and deregistration functions.
- Added support functions which will be invoked on adapter
  add/remove and port up/down events.
- Traverses through the list of adapters for invoking callback functions

Signed-off-by: Parav Pandit 
---
 drivers/net/ethernet/emulex/benet/Makefile  |2 +-
 drivers/net/ethernet/emulex/benet/be.h  |   38 ++-
 drivers/net/ethernet/emulex/benet/be_cmds.h |1 +
 drivers/net/ethernet/emulex/benet/be_hw.h   |4 +-
 drivers/net/ethernet/emulex/benet/be_main.c |   88 +++--
 drivers/net/ethernet/emulex/benet/be_roce.c |  182 +++
 drivers/net/ethernet/emulex/benet/be_roce.h |   75 +++
 7 files changed, 375 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/ethernet/emulex/benet/be_roce.c
 create mode 100644 drivers/net/ethernet/emulex/benet/be_roce.h

diff --git a/drivers/net/ethernet/emulex/benet/Makefile 
b/drivers/net/ethernet/emulex/benet/Makefile
index a60cd80..1a91b27 100644
--- a/drivers/net/ethernet/emulex/benet/Makefile
+++ b/drivers/net/ethernet/emulex/benet/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_BE2NET) += be2net.o
 
-be2net-y :=  be_main.o be_cmds.o be_ethtool.o
+be2net-y :=  be_main.o be_cmds.o be_ethtool.o be_roce.o
diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index ab24e46..15d0c88 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -32,6 +32,7 @@
 #include 
 
 #include "be_hw.h"
+#include "be_roce.h"
 
 #define DRV_VER"4.2.116u"
 #define DRV_NAME   "be2net"
@@ -98,7 +99,8 @@ static inline char *nic_name(struct pci_dev *pdev)
 #define MAX_RX_QS  (MAX_RSS_QS + 1) /* RSS qs + 1 def Rx */
 
 #define MAX_TX_QS  8
-#define MAX_MSIX_VECTORS   MAX_RSS_QS
+#define MAX_ROCE_EQS   5
+#define MAX_MSIX_VECTORS   (MAX_RSS_QS + MAX_ROCE_EQS) /* RSS qs + RoCE */
 #define BE_TX_BUDGET   256
 #define BE_NAPI_WEIGHT 64
 #define MAX_RX_POSTBE_NAPI_WEIGHT /* Frags posted at a time */
@@ -376,6 +378,17 @@ struct be_adapter {
u8 transceiver;
u8 autoneg;
u8 generation;  /* BladeEngine ASIC generation */
+   u32 if_type;
+   struct {
+   u8 __iomem *base;   /* Door Bell */
+   u32 size;
+   u32 total_size;
+   u64 io_addr;
+   } roce_db;
+   u32 num_msix_roce_vec;
+   struct ocrdma_dev *ocrdma_dev;
+   struct list_head entry;
+
u32 flash_status;
struct completion flash_compl;
 
@@ -403,6 +416,10 @@ struct be_adapter {
 #define lancer_chip(adapter)   ((adapter->pdev->device == OC_DEVICE_ID3) || \
 (adapter->pdev->device == OC_DEVICE_ID4))
 
+#define be_roce_supported(adapter) ((adapter->if_type == SLI_INTF_TYPE_3 || \
+   adapter->sli_family == SKYHAWK_SLI_FAMILY) && \
+   (adapter->function_mode & RDMA_ENABLED))
+
 extern const struct ethtool_ops be_ethtool_ops;
 
 #define msix_enabled(adapter)  (adapter->num_msix_vec > 0)
@@ -549,9 +566,28 @@ static inline bool be_error(struct be_adapter *adapter)
return adapter->eeh_err || adapter->ue_detected || adapter->fw_timeout;
 }
 
+static inline bool be_type_2_3(struct be_adapter *adapter)
+{
+   return (adapter->if_type == SLI_INTF_TYPE_2 ||
+   adapter->if_type == SLI_INTF_TYPE_3) ? true : false;
+}
+
 extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm,
u16 num_popped);
 extern void be_link_status_update(struct be_adapter *adapter, u8 link_status);
 extern void be_parse_stats(struct be_adapter *adapter);
 extern int be_load_fw(struct be_adapter *adapter, u8 *func);
+
+/*
+ * internal function to initialize-cleanup roce device.
+ */
+extern void be_roce_dev_add(struct be_adapter *);
+extern void be_roce_dev_remove(struct be_adapter *);
+
+/*
+ * internal function to open-close roce device during ifup-ifdown.
+ */
+extern void be_roce_dev_open(struct be_adapter *);
+extern void be_roce_dev_close(struct be_adapter *);
+
 #endif /* BE_H */
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 687c420..b457532 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1054,6 +1054,7 @@ struct be_cmd_resp_modify_eq_delay {
 /* The HW can come up in either of the following multi-channel modes
  * based on the skew/IPL.
  */
+#define RDMA_ENABLED   0x4
 #define FLEX10_MODE0x400
 #define VNIC_MODE   

[PATCH 2/2] be2net: Added functionality to support RoCE driver

2012-03-07 Thread parav.pandit
From: Parav Pandit 

- Increased MSIX vectors by 5 for RoCE traffic.
- Added macro to check roce support on a device.
- Added device specific doorbell, msix vector fields shared with nic 
functionality.
- Provides RoCE driver registration and deregistration functions.
- Added support functions which will be invoked on adapter
  add/remove and port up/down events.
- Traverses through the list of adapters for invoking callback functions.

Signed-off-by: Parav Pandit 
---
 drivers/net/ethernet/emulex/benet/Makefile  |2 +-
 drivers/net/ethernet/emulex/benet/be.h  |   28 -
 drivers/net/ethernet/emulex/benet/be_cmds.h |1 +
 drivers/net/ethernet/emulex/benet/be_hw.h   |4 +-
 drivers/net/ethernet/emulex/benet/be_main.c |   83 +++--
 drivers/net/ethernet/emulex/benet/be_roce.c |  185 +++
 drivers/net/ethernet/emulex/benet/be_roce.h |   75 +++
 7 files changed, 365 insertions(+), 13 deletions(-)
 create mode 100644 drivers/net/ethernet/emulex/benet/be_roce.c
 create mode 100644 drivers/net/ethernet/emulex/benet/be_roce.h

diff --git a/drivers/net/ethernet/emulex/benet/Makefile 
b/drivers/net/ethernet/emulex/benet/Makefile
index a60cd80..1a91b27 100644
--- a/drivers/net/ethernet/emulex/benet/Makefile
+++ b/drivers/net/ethernet/emulex/benet/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_BE2NET) += be2net.o
 
-be2net-y :=  be_main.o be_cmds.o be_ethtool.o
+be2net-y :=  be_main.o be_cmds.o be_ethtool.o be_roce.o
diff --git a/drivers/net/ethernet/emulex/benet/be.h 
b/drivers/net/ethernet/emulex/benet/be.h
index cbdec25..767f41f 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -32,6 +32,7 @@
 #include 
 
 #include "be_hw.h"
+#include "be_roce.h"
 
 #define DRV_VER"4.0.100u"
 #define DRV_NAME   "be2net"
@@ -92,7 +93,7 @@ static inline char *nic_name(struct pci_dev *pdev)
 #define MAX_RSS_QS 4   /* BE limit is 4 queues/port */
 #define MAX_RX_QS  (MAX_RSS_QS + 1) /* RSS qs + 1 def Rx */
 #define MAX_TX_QS  8
-#define BE_MAX_MSIX_VECTORS(MAX_RX_QS + 1)/* RX + TX */
+#define BE_MAX_MSIX_VECTORS(MAX_RX_QS + 1 + 5)/* RX + TX  + 5 RoCE */
 #define BE_NAPI_WEIGHT 64
 #define MAX_RX_POSTBE_NAPI_WEIGHT /* Frags posted at a time */
 #define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST)
@@ -320,6 +321,7 @@ struct be_adapter {
 
struct msix_entry msix_entries[BE_MAX_MSIX_VECTORS];
u32 num_msix_vec;
+   u32 num_eqs;
bool isr_registered;
 
/* TX Rings */
@@ -372,6 +374,14 @@ struct be_adapter {
u8 transceiver;
u8 autoneg;
u8 generation;  /* BladeEngine ASIC generation */
+   u32 if_type;
+   u8 __iomem *roce_db;/* Door Bell */
+   u32 roce_db_size;
+   u32 roce_db_total_size;
+   u64 roce_db_io_addr;
+   void *ocrdma_dev;
+   struct list_head entry;
+
u32 flash_status;
struct completion flash_compl;
 
@@ -398,6 +408,9 @@ struct be_adapter {
 #define OFF0
 #define lancer_chip(adapter)   ((adapter->pdev->device == OC_DEVICE_ID3) || \
 (adapter->pdev->device == OC_DEVICE_ID4))
+#define be_roce_supported(adapter) ((adapter->if_type == SLI_INTF_TYPE_3 || \
+   adapter->sli_family == SKYHAWK_SLI_FAMILY) && \
+   (adapter->function_mode & RDMA_ENABLED))
 
 extern const struct ethtool_ops be_ethtool_ops;
 
@@ -544,4 +557,17 @@ extern void be_cq_notify(struct be_adapter *adapter, u16 
qid, bool arm,
 extern void be_link_status_update(struct be_adapter *adapter, u8 link_status);
 extern void be_parse_stats(struct be_adapter *adapter);
 extern int be_load_fw(struct be_adapter *adapter, u8 *func);
+
+/*
+ * internal function to initialize-cleanup roce device.
+ */
+extern void be_roce_dev_add(struct be_adapter *adapter);
+extern void be_roce_dev_remove(struct be_adapter *adapter);
+
+/*
+ * internal function to open-close roce device during ifup-ifdown.
+ */
+extern void be_roce_dev_open(struct be_adapter *adapter);
+extern void be_roce_dev_close(struct be_adapter *adapter);
+
 #endif /* BE_H */
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h 
b/drivers/net/ethernet/emulex/benet/be_cmds.h
index dca8924..d7ad03b 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1057,6 +1057,7 @@ struct be_cmd_resp_modify_eq_delay {
 #define FLEX10_MODE0x400
 #define VNIC_MODE  0x2
 #define UMC_ENABLED0x100
+#define RDMA_ENABLED   0x4
 struct be_cmd_req_query_fw_cfg {
struct be_cmd_req_hdr hdr;
u32 rsvd[31];
diff --git a/drivers/net/ethernet/emulex/benet/be_hw.h 
b/drivers/net/ethernet/emulex/benet/be_hw.h
inde