Skip to content

Commit

Permalink
IB/usnic: Add Cisco VIC low-level hardware driver
Browse files Browse the repository at this point in the history
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
Upinder Malhi authored and rolandd committed Jan 14, 2014
1 parent 7e22e91 commit e3cf00d
Show file tree
Hide file tree
Showing 30 changed files with 4,904 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,11 @@ M: Nishank Trivedi <nistrive@cisco.com>
S: Supported
F: drivers/net/ethernet/cisco/enic/

CISCO VIC LOW LATENCY NIC DRIVER
M: Upinder Malhi <umalhi@cisco.com>
S: Supported
F: drivers/infiniband/hw/usnic

CIRRUS LOGIC EP93XX ETHERNET DRIVER
M: Hartley Sweeten <hsweeten@visionengravers.com>
L: netdev@vger.kernel.org
Expand Down
1 change: 1 addition & 0 deletions drivers/infiniband/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ source "drivers/infiniband/hw/mlx4/Kconfig"
source "drivers/infiniband/hw/mlx5/Kconfig"
source "drivers/infiniband/hw/nes/Kconfig"
source "drivers/infiniband/hw/ocrdma/Kconfig"
source "drivers/infiniband/hw/usnic/Kconfig"

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

Expand Down
1 change: 1 addition & 0 deletions drivers/infiniband/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ obj-$(CONFIG_MLX4_INFINIBAND) += hw/mlx4/
obj-$(CONFIG_MLX5_INFINIBAND) += hw/mlx5/
obj-$(CONFIG_INFINIBAND_NES) += hw/nes/
obj-$(CONFIG_INFINIBAND_OCRDMA) += hw/ocrdma/
obj-$(CONFIG_INFINIBAND_USNIC) += hw/usnic/
obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/
obj-$(CONFIG_INFINIBAND_SRP) += ulp/srp/
obj-$(CONFIG_INFINIBAND_SRPT) += ulp/srpt/
Expand Down
10 changes: 10 additions & 0 deletions drivers/infiniband/hw/usnic/Kconfig
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.
15 changes: 15 additions & 0 deletions drivers/infiniband/hw/usnic/Makefile
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 \
29 changes: 29 additions & 0 deletions drivers/infiniband/hw/usnic/usnic.h
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_ */
56 changes: 56 additions & 0 deletions drivers/infiniband/hw/usnic/usnic_abi.h
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 */
27 changes: 27 additions & 0 deletions drivers/infiniband/hw/usnic/usnic_common_pkt_hdr.h
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 */
51 changes: 51 additions & 0 deletions drivers/infiniband/hw/usnic/usnic_common_util.h
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 */
71 changes: 71 additions & 0 deletions drivers/infiniband/hw/usnic/usnic_debugfs.c
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;
}
25 changes: 25 additions & 0 deletions drivers/infiniband/hw/usnic/usnic_debugfs.h
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_ */
Loading

0 comments on commit e3cf00d

Please sign in to comment.