forked from whatawurst/android_kernel_sony_msm8998
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IB/usnic: Add Cisco VIC low-level hardware driver
This adds a driver that allows userspace to use UD-like QPs over a proprietary Cisco transport with Cisco's Virtual Interface Cards (VICs), including VIC 1240 and 1280 cards. Signed-off-by: Upinder Malhi <umalhi@cisco.com> Signed-off-by: Christian Benvenuti <benve@cisco.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
- Loading branch information
Showing
30 changed files
with
4,904 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
config INFINIBAND_USNIC | ||
tristate "Verbs support for Cisco VIC" | ||
depends on NETDEVICES && ETHERNET && PCI && INTEL_IOMMU | ||
select ENIC | ||
select NET_VENDOR_CISCO | ||
select PCI_IOV | ||
select INFINIBAND_USER_ACCESS | ||
---help--- | ||
This is a low-level driver for Cisco's Virtual Interface | ||
Cards (VICs), including the VIC 1240 and 1280 cards. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ccflags-y := -Idrivers/net/ethernet/cisco/enic | ||
|
||
obj-$(CONFIG_INFINIBAND_USNIC)+= usnic_verbs.o | ||
|
||
usnic_verbs-y=\ | ||
usnic_fwd.o \ | ||
usnic_transport.o \ | ||
usnic_uiom.o \ | ||
usnic_uiom_interval_tree.o \ | ||
usnic_vnic.o \ | ||
usnic_ib_main.o \ | ||
usnic_ib_qp_grp.o \ | ||
usnic_ib_sysfs.o \ | ||
usnic_ib_verbs.o \ | ||
usnic_debugfs.o \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. | ||
* | ||
* This program is free software; you may redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
|
||
#ifndef USNIC_H_ | ||
#define USNIC_H_ | ||
|
||
#define DRV_NAME "usnic_verbs" | ||
|
||
#define PCI_DEVICE_ID_CISCO_VIC_USPACE_NIC 0x00cf /* User space NIC */ | ||
|
||
#define DRV_VERSION "1.0.2" | ||
#define DRV_RELDATE "September 09, 2013" | ||
|
||
#endif /* USNIC_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. | ||
* | ||
* This program is free software; you may redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
|
||
|
||
#ifndef USNIC_ABI_H | ||
#define USNIC_ABI_H | ||
|
||
/* ABI between userspace and kernel */ | ||
#define USNIC_UVERBS_ABI_VERSION 2 | ||
|
||
#define USNIC_QP_GRP_MAX_WQS 8 | ||
#define USNIC_QP_GRP_MAX_RQS 8 | ||
#define USNIC_QP_GRP_MAX_CQS 16 | ||
|
||
enum usnic_transport_type { | ||
USNIC_TRANSPORT_UNKNOWN = 0, | ||
USNIC_TRANSPORT_ROCE_CUSTOM = 1, | ||
USNIC_TRANSPORT_MAX = 2, | ||
}; | ||
|
||
/*TODO: Future - usnic_modify_qp needs to pass in generic filters */ | ||
struct usnic_ib_create_qp_resp { | ||
u32 vfid; | ||
u32 qp_grp_id; | ||
u64 bar_bus_addr; | ||
u32 bar_len; | ||
/* | ||
* WQ, RQ, CQ are explicity specified bc exposing a generic resources inteface | ||
* expands the scope of ABI to many files. | ||
*/ | ||
u32 wq_cnt; | ||
u32 rq_cnt; | ||
u32 cq_cnt; | ||
u32 wq_idx[USNIC_QP_GRP_MAX_WQS]; | ||
u32 rq_idx[USNIC_QP_GRP_MAX_RQS]; | ||
u32 cq_idx[USNIC_QP_GRP_MAX_CQS]; | ||
u32 transport; | ||
u32 reserved[9]; | ||
}; | ||
|
||
#endif /* USNIC_ABI_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. | ||
* | ||
* This program is free software; you may redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
|
||
#ifndef USNIC_CMN_PKT_HDR_H | ||
#define USNIC_CMN_PKT_HDR_H | ||
|
||
#define USNIC_ROCE_ETHERTYPE (0x8915) | ||
#define USNIC_ROCE_GRH_VER (8) | ||
#define USNIC_PROTO_VER (1) | ||
#define USNIC_ROCE_GRH_VER_SHIFT (4) | ||
|
||
#endif /* USNIC_COMMON_PKT_HDR_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. | ||
* | ||
* This program is free software; you may redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
|
||
#ifndef USNIC_CMN_UTIL_H | ||
#define USNIC_CMN_UTIL_H | ||
|
||
static inline void | ||
usnic_mac_to_gid(const char *const mac, char *raw_gid) | ||
{ | ||
raw_gid[0] = 0xfe; | ||
raw_gid[1] = 0x80; | ||
memset(&raw_gid[2], 0, 6); | ||
raw_gid[8] = mac[0]^2; | ||
raw_gid[9] = mac[1]; | ||
raw_gid[10] = mac[2]; | ||
raw_gid[11] = 0xff; | ||
raw_gid[12] = 0xfe; | ||
raw_gid[13] = mac[3]; | ||
raw_gid[14] = mac[4]; | ||
raw_gid[15] = mac[5]; | ||
} | ||
|
||
static inline void | ||
usnic_write_gid_if_id_from_mac(char *mac, char *raw_gid) | ||
{ | ||
raw_gid[8] = mac[0]^2; | ||
raw_gid[9] = mac[1]; | ||
raw_gid[10] = mac[2]; | ||
raw_gid[11] = 0xff; | ||
raw_gid[12] = 0xfe; | ||
raw_gid[13] = mac[3]; | ||
raw_gid[14] = mac[4]; | ||
raw_gid[15] = mac[5]; | ||
} | ||
|
||
#endif /* USNIC_COMMON_UTIL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. | ||
* | ||
* This program is free software; you may redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
|
||
#include <linux/debugfs.h> | ||
#include <linux/module.h> | ||
|
||
#include "usnic.h" | ||
#include "usnic_log.h" | ||
#include "usnic_debugfs.h" | ||
|
||
static struct dentry *debugfs_root; | ||
|
||
static ssize_t usnic_debugfs_buildinfo_read(struct file *f, char __user *data, | ||
size_t count, loff_t *ppos) | ||
{ | ||
char buf[500]; | ||
int res; | ||
|
||
if (*ppos > 0) | ||
return 0; | ||
|
||
res = scnprintf(buf, sizeof(buf), | ||
"version: %s\n" | ||
"build date: %s\n", | ||
DRV_VERSION, DRV_RELDATE); | ||
|
||
return simple_read_from_buffer(data, count, ppos, buf, res); | ||
} | ||
|
||
static const struct file_operations usnic_debugfs_buildinfo_ops = { | ||
.owner = THIS_MODULE, | ||
.open = simple_open, | ||
.read = usnic_debugfs_buildinfo_read | ||
}; | ||
|
||
void usnic_debugfs_init(void) | ||
{ | ||
debugfs_root = debugfs_create_dir(DRV_NAME, NULL); | ||
if (IS_ERR(debugfs_root)) { | ||
usnic_err("Failed to create debugfs root dir, check if debugfs is enabled in kernel configuration\n"); | ||
debugfs_root = NULL; | ||
return; | ||
} | ||
|
||
debugfs_create_file("build-info", S_IRUGO, debugfs_root, | ||
NULL, &usnic_debugfs_buildinfo_ops); | ||
} | ||
|
||
void usnic_debugfs_exit(void) | ||
{ | ||
if (!debugfs_root) | ||
return; | ||
|
||
debugfs_remove_recursive(debugfs_root); | ||
debugfs_root = NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. | ||
* | ||
* This program is free software; you may redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; version 2 of the License. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
* | ||
*/ | ||
#ifndef USNIC_DEBUGFS_H_ | ||
#define USNIC_DEBUGFS_H_ | ||
|
||
void usnic_debugfs_init(void); | ||
|
||
void usnic_debugfs_exit(void); | ||
|
||
#endif /*!USNIC_DEBUGFS_H_ */ |
Oops, something went wrong.