Skip to content

Commit e3cf00d

Browse files
Upinder Malhirolandd
authored andcommitted
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>
1 parent 7e22e91 commit e3cf00d

30 files changed

+4904
-0
lines changed

MAINTAINERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,11 @@ M: Nishank Trivedi <nistrive@cisco.com>
21582158
S: Supported
21592159
F: drivers/net/ethernet/cisco/enic/
21602160

2161+
CISCO VIC LOW LATENCY NIC DRIVER
2162+
M: Upinder Malhi <umalhi@cisco.com>
2163+
S: Supported
2164+
F: drivers/infiniband/hw/usnic
2165+
21612166
CIRRUS LOGIC EP93XX ETHERNET DRIVER
21622167
M: Hartley Sweeten <hsweeten@visionengravers.com>
21632168
L: netdev@vger.kernel.org

drivers/infiniband/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ source "drivers/infiniband/hw/mlx4/Kconfig"
5353
source "drivers/infiniband/hw/mlx5/Kconfig"
5454
source "drivers/infiniband/hw/nes/Kconfig"
5555
source "drivers/infiniband/hw/ocrdma/Kconfig"
56+
source "drivers/infiniband/hw/usnic/Kconfig"
5657

5758
source "drivers/infiniband/ulp/ipoib/Kconfig"
5859

drivers/infiniband/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ obj-$(CONFIG_MLX4_INFINIBAND) += hw/mlx4/
1010
obj-$(CONFIG_MLX5_INFINIBAND) += hw/mlx5/
1111
obj-$(CONFIG_INFINIBAND_NES) += hw/nes/
1212
obj-$(CONFIG_INFINIBAND_OCRDMA) += hw/ocrdma/
13+
obj-$(CONFIG_INFINIBAND_USNIC) += hw/usnic/
1314
obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/
1415
obj-$(CONFIG_INFINIBAND_SRP) += ulp/srp/
1516
obj-$(CONFIG_INFINIBAND_SRPT) += ulp/srpt/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
config INFINIBAND_USNIC
2+
tristate "Verbs support for Cisco VIC"
3+
depends on NETDEVICES && ETHERNET && PCI && INTEL_IOMMU
4+
select ENIC
5+
select NET_VENDOR_CISCO
6+
select PCI_IOV
7+
select INFINIBAND_USER_ACCESS
8+
---help---
9+
This is a low-level driver for Cisco's Virtual Interface
10+
Cards (VICs), including the VIC 1240 and 1280 cards.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ccflags-y := -Idrivers/net/ethernet/cisco/enic
2+
3+
obj-$(CONFIG_INFINIBAND_USNIC)+= usnic_verbs.o
4+
5+
usnic_verbs-y=\
6+
usnic_fwd.o \
7+
usnic_transport.o \
8+
usnic_uiom.o \
9+
usnic_uiom_interval_tree.o \
10+
usnic_vnic.o \
11+
usnic_ib_main.o \
12+
usnic_ib_qp_grp.o \
13+
usnic_ib_sysfs.o \
14+
usnic_ib_verbs.o \
15+
usnic_debugfs.o \
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3+
*
4+
* This program is free software; you may redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 2 of the License.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15+
* SOFTWARE.
16+
*
17+
*/
18+
19+
#ifndef USNIC_H_
20+
#define USNIC_H_
21+
22+
#define DRV_NAME "usnic_verbs"
23+
24+
#define PCI_DEVICE_ID_CISCO_VIC_USPACE_NIC 0x00cf /* User space NIC */
25+
26+
#define DRV_VERSION "1.0.2"
27+
#define DRV_RELDATE "September 09, 2013"
28+
29+
#endif /* USNIC_H_ */
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3+
*
4+
* This program is free software; you may redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 2 of the License.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15+
* SOFTWARE.
16+
*
17+
*/
18+
19+
20+
#ifndef USNIC_ABI_H
21+
#define USNIC_ABI_H
22+
23+
/* ABI between userspace and kernel */
24+
#define USNIC_UVERBS_ABI_VERSION 2
25+
26+
#define USNIC_QP_GRP_MAX_WQS 8
27+
#define USNIC_QP_GRP_MAX_RQS 8
28+
#define USNIC_QP_GRP_MAX_CQS 16
29+
30+
enum usnic_transport_type {
31+
USNIC_TRANSPORT_UNKNOWN = 0,
32+
USNIC_TRANSPORT_ROCE_CUSTOM = 1,
33+
USNIC_TRANSPORT_MAX = 2,
34+
};
35+
36+
/*TODO: Future - usnic_modify_qp needs to pass in generic filters */
37+
struct usnic_ib_create_qp_resp {
38+
u32 vfid;
39+
u32 qp_grp_id;
40+
u64 bar_bus_addr;
41+
u32 bar_len;
42+
/*
43+
* WQ, RQ, CQ are explicity specified bc exposing a generic resources inteface
44+
* expands the scope of ABI to many files.
45+
*/
46+
u32 wq_cnt;
47+
u32 rq_cnt;
48+
u32 cq_cnt;
49+
u32 wq_idx[USNIC_QP_GRP_MAX_WQS];
50+
u32 rq_idx[USNIC_QP_GRP_MAX_RQS];
51+
u32 cq_idx[USNIC_QP_GRP_MAX_CQS];
52+
u32 transport;
53+
u32 reserved[9];
54+
};
55+
56+
#endif /* USNIC_ABI_H */
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3+
*
4+
* This program is free software; you may redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 2 of the License.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15+
* SOFTWARE.
16+
*
17+
*/
18+
19+
#ifndef USNIC_CMN_PKT_HDR_H
20+
#define USNIC_CMN_PKT_HDR_H
21+
22+
#define USNIC_ROCE_ETHERTYPE (0x8915)
23+
#define USNIC_ROCE_GRH_VER (8)
24+
#define USNIC_PROTO_VER (1)
25+
#define USNIC_ROCE_GRH_VER_SHIFT (4)
26+
27+
#endif /* USNIC_COMMON_PKT_HDR_H */
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3+
*
4+
* This program is free software; you may redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 2 of the License.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15+
* SOFTWARE.
16+
*
17+
*/
18+
19+
#ifndef USNIC_CMN_UTIL_H
20+
#define USNIC_CMN_UTIL_H
21+
22+
static inline void
23+
usnic_mac_to_gid(const char *const mac, char *raw_gid)
24+
{
25+
raw_gid[0] = 0xfe;
26+
raw_gid[1] = 0x80;
27+
memset(&raw_gid[2], 0, 6);
28+
raw_gid[8] = mac[0]^2;
29+
raw_gid[9] = mac[1];
30+
raw_gid[10] = mac[2];
31+
raw_gid[11] = 0xff;
32+
raw_gid[12] = 0xfe;
33+
raw_gid[13] = mac[3];
34+
raw_gid[14] = mac[4];
35+
raw_gid[15] = mac[5];
36+
}
37+
38+
static inline void
39+
usnic_write_gid_if_id_from_mac(char *mac, char *raw_gid)
40+
{
41+
raw_gid[8] = mac[0]^2;
42+
raw_gid[9] = mac[1];
43+
raw_gid[10] = mac[2];
44+
raw_gid[11] = 0xff;
45+
raw_gid[12] = 0xfe;
46+
raw_gid[13] = mac[3];
47+
raw_gid[14] = mac[4];
48+
raw_gid[15] = mac[5];
49+
}
50+
51+
#endif /* USNIC_COMMON_UTIL_H */
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3+
*
4+
* This program is free software; you may redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 2 of the License.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15+
* SOFTWARE.
16+
*
17+
*/
18+
19+
#include <linux/debugfs.h>
20+
#include <linux/module.h>
21+
22+
#include "usnic.h"
23+
#include "usnic_log.h"
24+
#include "usnic_debugfs.h"
25+
26+
static struct dentry *debugfs_root;
27+
28+
static ssize_t usnic_debugfs_buildinfo_read(struct file *f, char __user *data,
29+
size_t count, loff_t *ppos)
30+
{
31+
char buf[500];
32+
int res;
33+
34+
if (*ppos > 0)
35+
return 0;
36+
37+
res = scnprintf(buf, sizeof(buf),
38+
"version: %s\n"
39+
"build date: %s\n",
40+
DRV_VERSION, DRV_RELDATE);
41+
42+
return simple_read_from_buffer(data, count, ppos, buf, res);
43+
}
44+
45+
static const struct file_operations usnic_debugfs_buildinfo_ops = {
46+
.owner = THIS_MODULE,
47+
.open = simple_open,
48+
.read = usnic_debugfs_buildinfo_read
49+
};
50+
51+
void usnic_debugfs_init(void)
52+
{
53+
debugfs_root = debugfs_create_dir(DRV_NAME, NULL);
54+
if (IS_ERR(debugfs_root)) {
55+
usnic_err("Failed to create debugfs root dir, check if debugfs is enabled in kernel configuration\n");
56+
debugfs_root = NULL;
57+
return;
58+
}
59+
60+
debugfs_create_file("build-info", S_IRUGO, debugfs_root,
61+
NULL, &usnic_debugfs_buildinfo_ops);
62+
}
63+
64+
void usnic_debugfs_exit(void)
65+
{
66+
if (!debugfs_root)
67+
return;
68+
69+
debugfs_remove_recursive(debugfs_root);
70+
debugfs_root = NULL;
71+
}

0 commit comments

Comments
 (0)