[PATCH V1 1/2] be2net: Added function to issue mailbox cmd on MQ.

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

- Added generic function to issue mailbox cmd on MQ as export function.
- RoCE driver will use this before it setups its own MQ.

Signed-off-by: Parav Pandit 
---
 drivers/net/ethernet/emulex/benet/be_cmds.c |   39 +++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c 
b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 0fcb456..19037b0 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -15,6 +15,7 @@
  * Costa Mesa, CA 92626
  */
 
+#include 
 #include "be.h"
 #include "be_cmds.h"
 
@@ -2391,3 +2392,41 @@ err:
spin_unlock_bh(&adapter->mcc_lock);
return status;
 }
+
+int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload,
+   int wrb_payload_size, u16 *cmd_status, u16 *ext_status)
+{
+   struct be_adapter *adapter = netdev_priv(netdev_handle);
+   struct be_mcc_wrb *wrb;
+   struct be_cmd_req_hdr *hdr = (struct be_cmd_req_hdr *) wrb_payload;
+   struct be_cmd_req_hdr *req;
+   struct be_cmd_resp_hdr *resp;
+   int status;
+
+   spin_lock_bh(&adapter->mcc_lock);
+
+   wrb = wrb_from_mccq(adapter);
+   if (!wrb) {
+   status = -EBUSY;
+   goto err;
+   }
+   req = embedded_payload(wrb);
+   resp = embedded_payload(wrb);
+
+   be_wrb_cmd_hdr_prepare(req, hdr->subsystem,
+  hdr->opcode, wrb_payload_size, wrb, NULL);
+   memcpy(req, wrb_payload, wrb_payload_size);
+   be_dws_cpu_to_le(req, wrb_payload_size);
+
+   status = be_mcc_notify_wait(adapter);
+   if (cmd_status)
+   *cmd_status = (status & 0x);
+   if (ext_status)
+   *ext_status = 0;
+   memcpy(wrb_payload, resp, sizeof(*resp) + resp->response_length);
+   be_dws_le_to_cpu(wrb_payload, sizeof(*resp) + resp->response_length);
+err:
+   spin_unlock_bh(&adapter->mcc_lock);
+   return status;
+}
+EXPORT_SYMBOL(be_roce_mcc_cmd);
-- 
1.6.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2012-03-10 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 |   83 ++--
 drivers/net/ethernet/emulex/benet/be_roce.c |  183 +++
 drivers/net/ethernet/emulex/benet/be_roce.h |   75 +++
 7 files changed, 370 insertions(+), 16 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..fc094d9 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,16 @@ 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;
+   struct ocrdma_dev *ocrdma_dev;
+   struct list_head entry;
+
u32 flash_status;
struct completion flash_compl;
 
@@ -399,6 +411,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)
@@ -539,9 +555,29 @@ 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 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

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

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

This patch addresses all the review comments given by Francois Romieu &
David Laight for past patch except be_roce_supported() macro as it
breaks the modularity of be_cmds.x

This patch adds functionality to support RoCE (RDMA over Ethernet) driver.
- Detecting RoCE supported adapters and creating linked list of them.
- Enabling 5 more MSIX vectors for RoCE functionality.
- Calling registered callback functions of the RoCE driver
  whenever new RoCE capable device is added/removed.
- Notifying events to RoCE driver when interface is up or down.
- Provides device specific details to RoCE driver for each roce device.
- Provides low level mailbox command to be issued by RoCE driver
  before it can have it own MQ.

Parav Pandit (2):
  be2net: Added function to issue mailbox cmd on MQ.
  be2net: Added functionality to support RoCE driver

 drivers/net/ethernet/emulex/benet/Makefile  |2 +-
 drivers/net/ethernet/emulex/benet/be.h  |   38 ++-
 drivers/net/ethernet/emulex/benet/be_cmds.c |   39 ++
 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 |  183 +++
 drivers/net/ethernet/emulex/benet/be_roce.h |   75 +++
 8 files changed, 409 insertions(+), 16 deletions(-)
 create mode 100644 drivers/net/ethernet/emulex/benet/be_roce.c
 create mode 100644 drivers/net/ethernet/emulex/benet/be_roce.h

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html