You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
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>
This commit is contained in:
committed by
Roland Dreier
parent
7e22e91102
commit
e3cf00d0a8
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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/
|
||||
|
||||
10
drivers/infiniband/hw/usnic/Kconfig
Normal file
10
drivers/infiniband/hw/usnic/Kconfig
Normal file
@@ -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
drivers/infiniband/hw/usnic/Makefile
Normal file
15
drivers/infiniband/hw/usnic/Makefile
Normal file
@@ -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
drivers/infiniband/hw/usnic/usnic.h
Normal file
29
drivers/infiniband/hw/usnic/usnic.h
Normal file
@@ -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
drivers/infiniband/hw/usnic/usnic_abi.h
Normal file
56
drivers/infiniband/hw/usnic/usnic_abi.h
Normal file
@@ -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
drivers/infiniband/hw/usnic/usnic_common_pkt_hdr.h
Normal file
27
drivers/infiniband/hw/usnic/usnic_common_pkt_hdr.h
Normal file
@@ -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
drivers/infiniband/hw/usnic/usnic_common_util.h
Normal file
51
drivers/infiniband/hw/usnic/usnic_common_util.h
Normal file
@@ -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
drivers/infiniband/hw/usnic/usnic_debugfs.c
Normal file
71
drivers/infiniband/hw/usnic/usnic_debugfs.c
Normal file
@@ -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
drivers/infiniband/hw/usnic/usnic_debugfs.h
Normal file
25
drivers/infiniband/hw/usnic/usnic_debugfs.h
Normal file
@@ -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_ */
|
||||
243
drivers/infiniband/hw/usnic/usnic_fwd.c
Normal file
243
drivers/infiniband/hw/usnic/usnic_fwd.c
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* 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/netdevice.h>
|
||||
#include <linux/pci.h>
|
||||
|
||||
#include "enic_api.h"
|
||||
#include "usnic_common_pkt_hdr.h"
|
||||
#include "usnic_fwd.h"
|
||||
#include "usnic_log.h"
|
||||
|
||||
struct usnic_fwd_dev *usnic_fwd_dev_alloc(struct pci_dev *pdev)
|
||||
{
|
||||
struct usnic_fwd_dev *ufdev;
|
||||
|
||||
ufdev = kzalloc(sizeof(*ufdev), GFP_KERNEL);
|
||||
if (!ufdev)
|
||||
return NULL;
|
||||
|
||||
ufdev->pdev = pdev;
|
||||
ufdev->netdev = pci_get_drvdata(pdev);
|
||||
spin_lock_init(&ufdev->lock);
|
||||
|
||||
return ufdev;
|
||||
}
|
||||
|
||||
void usnic_fwd_dev_free(struct usnic_fwd_dev *ufdev)
|
||||
{
|
||||
kfree(ufdev);
|
||||
}
|
||||
|
||||
static int usnic_fwd_devcmd(struct usnic_fwd_dev *ufdev, int vnic_idx,
|
||||
enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1)
|
||||
{
|
||||
int status;
|
||||
struct net_device *netdev = ufdev->netdev;
|
||||
|
||||
spin_lock(&ufdev->lock);
|
||||
status = enic_api_devcmd_proxy_by_index(netdev,
|
||||
vnic_idx,
|
||||
cmd,
|
||||
a0, a1,
|
||||
1000);
|
||||
spin_unlock(&ufdev->lock);
|
||||
if (status) {
|
||||
if (status == ERR_EINVAL && cmd == CMD_DEL_FILTER) {
|
||||
usnic_dbg("Dev %s vnic idx %u cmd %u already deleted",
|
||||
netdev_name(netdev), vnic_idx, cmd);
|
||||
} else {
|
||||
usnic_err("Dev %s vnic idx %u cmd %u failed with status %d\n",
|
||||
netdev_name(netdev), vnic_idx, cmd,
|
||||
status);
|
||||
}
|
||||
} else {
|
||||
usnic_dbg("Dev %s vnic idx %u cmd %u success",
|
||||
netdev_name(netdev), vnic_idx,
|
||||
cmd);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int usnic_fwd_add_usnic_filter(struct usnic_fwd_dev *ufdev, int vnic_idx,
|
||||
int rq_idx, struct usnic_fwd_filter *fwd_filter,
|
||||
struct usnic_fwd_filter_hndl **filter_hndl)
|
||||
{
|
||||
struct filter_tlv *tlv, *tlv_va;
|
||||
struct filter *filter;
|
||||
struct filter_action *action;
|
||||
struct pci_dev *pdev;
|
||||
struct usnic_fwd_filter_hndl *usnic_filter_hndl;
|
||||
int status;
|
||||
u64 a0, a1;
|
||||
u64 tlv_size;
|
||||
dma_addr_t tlv_pa;
|
||||
|
||||
pdev = ufdev->pdev;
|
||||
tlv_size = (2*sizeof(struct filter_tlv) +
|
||||
sizeof(struct filter) +
|
||||
sizeof(struct filter_action));
|
||||
tlv = pci_alloc_consistent(pdev, tlv_size, &tlv_pa);
|
||||
if (!tlv) {
|
||||
usnic_err("Failed to allocate memory\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
usnic_filter_hndl = kzalloc(sizeof(*usnic_filter_hndl), GFP_ATOMIC);
|
||||
if (!usnic_filter_hndl) {
|
||||
usnic_err("Failed to allocate memory for hndl\n");
|
||||
pci_free_consistent(pdev, tlv_size, tlv, tlv_pa);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
tlv_va = tlv;
|
||||
a0 = tlv_pa;
|
||||
a1 = tlv_size;
|
||||
memset(tlv, 0, tlv_size);
|
||||
tlv->type = CLSF_TLV_FILTER;
|
||||
tlv->length = sizeof(struct filter);
|
||||
filter = (struct filter *)&tlv->val;
|
||||
filter->type = FILTER_USNIC_ID;
|
||||
filter->u.usnic.ethtype = USNIC_ROCE_ETHERTYPE;
|
||||
filter->u.usnic.flags = FILTER_FIELD_USNIC_ETHTYPE |
|
||||
FILTER_FIELD_USNIC_ID |
|
||||
FILTER_FIELD_USNIC_PROTO;
|
||||
filter->u.usnic.proto_version = (USNIC_ROCE_GRH_VER <<
|
||||
USNIC_ROCE_GRH_VER_SHIFT)
|
||||
| USNIC_PROTO_VER;
|
||||
filter->u.usnic.usnic_id = fwd_filter->port_num;
|
||||
tlv = (struct filter_tlv *)((char *)tlv + sizeof(struct filter_tlv) +
|
||||
sizeof(struct filter));
|
||||
tlv->type = CLSF_TLV_ACTION;
|
||||
tlv->length = sizeof(struct filter_action);
|
||||
action = (struct filter_action *)&tlv->val;
|
||||
action->type = FILTER_ACTION_RQ_STEERING;
|
||||
action->u.rq_idx = rq_idx;
|
||||
|
||||
status = usnic_fwd_devcmd(ufdev, vnic_idx, CMD_ADD_FILTER, &a0, &a1);
|
||||
pci_free_consistent(pdev, tlv_size, tlv_va, tlv_pa);
|
||||
if (status) {
|
||||
usnic_err("VF %s Filter add failed with status:%d",
|
||||
pci_name(pdev),
|
||||
status);
|
||||
kfree(usnic_filter_hndl);
|
||||
return status;
|
||||
} else {
|
||||
usnic_dbg("VF %s FILTER ID:%u",
|
||||
pci_name(pdev),
|
||||
(u32)a0);
|
||||
}
|
||||
|
||||
usnic_filter_hndl->type = FILTER_USNIC_ID;
|
||||
usnic_filter_hndl->id = (u32)a0;
|
||||
usnic_filter_hndl->vnic_idx = vnic_idx;
|
||||
usnic_filter_hndl->ufdev = ufdev;
|
||||
usnic_filter_hndl->filter = fwd_filter;
|
||||
*filter_hndl = usnic_filter_hndl;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int usnic_fwd_del_filter(struct usnic_fwd_filter_hndl *filter_hndl)
|
||||
{
|
||||
int status;
|
||||
u64 a0, a1;
|
||||
struct net_device *netdev;
|
||||
|
||||
netdev = filter_hndl->ufdev->netdev;
|
||||
a0 = filter_hndl->id;
|
||||
|
||||
status = usnic_fwd_devcmd(filter_hndl->ufdev, filter_hndl->vnic_idx,
|
||||
CMD_DEL_FILTER, &a0, &a1);
|
||||
if (status) {
|
||||
if (status == ERR_EINVAL) {
|
||||
usnic_dbg("Filter %u already deleted for VF Idx %u pf: %s status: %d",
|
||||
filter_hndl->id, filter_hndl->vnic_idx,
|
||||
netdev_name(netdev), status);
|
||||
status = 0;
|
||||
kfree(filter_hndl);
|
||||
} else {
|
||||
usnic_err("PF %s VF Idx %u Filter: %u FILTER DELETE failed with status %d",
|
||||
netdev_name(netdev),
|
||||
filter_hndl->vnic_idx, filter_hndl->id,
|
||||
status);
|
||||
}
|
||||
} else {
|
||||
usnic_dbg("PF %s VF Idx %u Filter: %u FILTER DELETED",
|
||||
netdev_name(netdev), filter_hndl->vnic_idx,
|
||||
filter_hndl->id);
|
||||
kfree(filter_hndl);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int usnic_fwd_enable_rq(struct usnic_fwd_dev *ufdev, int vnic_idx, int rq_idx)
|
||||
{
|
||||
int status;
|
||||
struct net_device *pf_netdev;
|
||||
u64 a0, a1;
|
||||
|
||||
pf_netdev = ufdev->netdev;
|
||||
a0 = rq_idx;
|
||||
a1 = CMD_QP_RQWQ;
|
||||
|
||||
status = usnic_fwd_devcmd(ufdev, vnic_idx, CMD_QP_ENABLE, &a0, &a1);
|
||||
|
||||
if (status) {
|
||||
usnic_err("PF %s VNIC Index %u RQ Index: %u ENABLE Failed with status %d",
|
||||
netdev_name(pf_netdev),
|
||||
vnic_idx,
|
||||
rq_idx,
|
||||
status);
|
||||
} else {
|
||||
usnic_dbg("PF %s VNIC Index %u RQ Index: %u ENABLED",
|
||||
netdev_name(pf_netdev),
|
||||
vnic_idx, rq_idx);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int usnic_fwd_disable_rq(struct usnic_fwd_dev *ufdev, int vnic_idx, int rq_idx)
|
||||
{
|
||||
int status;
|
||||
u64 a0, a1;
|
||||
struct net_device *pf_netdev;
|
||||
|
||||
pf_netdev = ufdev->netdev;
|
||||
a0 = rq_idx;
|
||||
a1 = CMD_QP_RQWQ;
|
||||
|
||||
status = usnic_fwd_devcmd(ufdev, vnic_idx, CMD_QP_DISABLE, &a0, &a1);
|
||||
|
||||
if (status) {
|
||||
usnic_err("PF %s VNIC Index %u RQ Index: %u DISABLE Failed with status %d",
|
||||
netdev_name(pf_netdev),
|
||||
vnic_idx,
|
||||
rq_idx,
|
||||
status);
|
||||
} else {
|
||||
usnic_dbg("PF %s VNIC Index %u RQ Index: %u DISABLED",
|
||||
netdev_name(pf_netdev),
|
||||
vnic_idx,
|
||||
rq_idx);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
58
drivers/infiniband/hw/usnic/usnic_fwd.h
Normal file
58
drivers/infiniband/hw/usnic/usnic_fwd.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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_FWD_H_
|
||||
#define USNIC_FWD_H_
|
||||
|
||||
#include <linux/if.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#include "usnic_abi.h"
|
||||
#include "vnic_devcmd.h"
|
||||
|
||||
struct usnic_fwd_dev {
|
||||
struct pci_dev *pdev;
|
||||
struct net_device *netdev;
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
struct usnic_fwd_filter {
|
||||
enum usnic_transport_type transport;
|
||||
u16 port_num;
|
||||
};
|
||||
|
||||
struct usnic_fwd_filter_hndl {
|
||||
enum filter_type type;
|
||||
u32 id;
|
||||
u32 vnic_idx;
|
||||
struct usnic_fwd_dev *ufdev;
|
||||
struct list_head link;
|
||||
struct usnic_fwd_filter *filter;
|
||||
};
|
||||
|
||||
struct usnic_fwd_dev *usnic_fwd_dev_alloc(struct pci_dev *pdev);
|
||||
void usnic_fwd_dev_free(struct usnic_fwd_dev *ufdev);
|
||||
int usnic_fwd_add_usnic_filter(struct usnic_fwd_dev *ufdev, int vnic_idx,
|
||||
int rq_idx, struct usnic_fwd_filter *filter,
|
||||
struct usnic_fwd_filter_hndl **filter_hndl);
|
||||
int usnic_fwd_del_filter(struct usnic_fwd_filter_hndl *filter_hndl);
|
||||
int usnic_fwd_enable_rq(struct usnic_fwd_dev *ufdev, int vnic_idx, int rq_idx);
|
||||
int usnic_fwd_disable_rq(struct usnic_fwd_dev *ufdev, int vnic_idx, int rq_idx);
|
||||
|
||||
#endif /* !USNIC_FWD_H_ */
|
||||
115
drivers/infiniband/hw/usnic/usnic_ib.h
Normal file
115
drivers/infiniband/hw/usnic/usnic_ib.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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_IB_H_
|
||||
#define USNIC_IB_H_
|
||||
|
||||
#include <linux/iommu.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <rdma/ib_verbs.h>
|
||||
|
||||
|
||||
#include "usnic.h"
|
||||
#include "usnic_abi.h"
|
||||
#include "usnic_vnic.h"
|
||||
|
||||
#define USNIC_IB_PORT_CNT 1
|
||||
#define USNIC_IB_NUM_COMP_VECTORS 1
|
||||
|
||||
extern unsigned int usnic_ib_share_vf;
|
||||
|
||||
struct usnic_ib_ucontext {
|
||||
struct ib_ucontext ibucontext;
|
||||
/* Protected by usnic_ib_dev->usdev_lock */
|
||||
struct list_head qp_grp_list;
|
||||
struct list_head link;
|
||||
};
|
||||
|
||||
struct usnic_ib_pd {
|
||||
struct ib_pd ibpd;
|
||||
struct usnic_uiom_pd *umem_pd;
|
||||
};
|
||||
|
||||
struct usnic_ib_mr {
|
||||
struct ib_mr ibmr;
|
||||
struct usnic_uiom_reg *umem;
|
||||
};
|
||||
|
||||
struct usnic_ib_dev {
|
||||
struct ib_device ib_dev;
|
||||
struct pci_dev *pdev;
|
||||
struct net_device *netdev;
|
||||
struct usnic_fwd_dev *ufdev;
|
||||
bool link_up;
|
||||
struct list_head ib_dev_link;
|
||||
struct list_head vf_dev_list;
|
||||
struct list_head ctx_list;
|
||||
struct mutex usdev_lock;
|
||||
char mac[ETH_ALEN];
|
||||
unsigned int mtu;
|
||||
|
||||
/* provisioning information */
|
||||
struct kref vf_cnt;
|
||||
unsigned int vf_res_cnt[USNIC_VNIC_RES_TYPE_MAX];
|
||||
|
||||
/* sysfs vars for QPN reporting */
|
||||
struct kobject *qpn_kobj;
|
||||
};
|
||||
|
||||
struct usnic_ib_vf {
|
||||
struct usnic_ib_dev *pf;
|
||||
spinlock_t lock;
|
||||
struct usnic_vnic *vnic;
|
||||
unsigned int qp_grp_ref_cnt;
|
||||
struct usnic_ib_pd *pd;
|
||||
struct list_head link;
|
||||
};
|
||||
|
||||
static inline
|
||||
struct usnic_ib_dev *to_usdev(struct ib_device *ibdev)
|
||||
{
|
||||
return container_of(ibdev, struct usnic_ib_dev, ib_dev);
|
||||
}
|
||||
|
||||
static inline
|
||||
struct usnic_ib_ucontext *to_ucontext(struct ib_ucontext *ibucontext)
|
||||
{
|
||||
return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
|
||||
}
|
||||
|
||||
static inline
|
||||
struct usnic_ib_pd *to_upd(struct ib_pd *ibpd)
|
||||
{
|
||||
return container_of(ibpd, struct usnic_ib_pd, ibpd);
|
||||
}
|
||||
|
||||
static inline
|
||||
struct usnic_ib_ucontext *to_uucontext(struct ib_ucontext *ibucontext)
|
||||
{
|
||||
return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
|
||||
}
|
||||
|
||||
static inline
|
||||
struct usnic_ib_mr *to_umr(struct ib_mr *ibmr)
|
||||
{
|
||||
return container_of(ibmr, struct usnic_ib_mr, ibmr);
|
||||
}
|
||||
void usnic_ib_log_vf(struct usnic_ib_vf *vf);
|
||||
#endif /* USNIC_IB_H_ */
|
||||
598
drivers/infiniband/hw/usnic/usnic_ib_main.c
Normal file
598
drivers/infiniband/hw/usnic/usnic_ib_main.c
Normal file
File diff suppressed because it is too large
Load Diff
541
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c
Normal file
541
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c
Normal file
File diff suppressed because it is too large
Load Diff
95
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h
Normal file
95
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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_IB_QP_GRP_H_
|
||||
#define USNIC_IB_QP_GRP_H_
|
||||
|
||||
#include <rdma/ib_verbs.h>
|
||||
|
||||
#include "usnic_ib.h"
|
||||
#include "usnic_abi.h"
|
||||
#include "usnic_fwd.h"
|
||||
#include "usnic_vnic.h"
|
||||
|
||||
#define MAX_QP_GRP_FILTERS 10
|
||||
#define DFLT_FILTER_IDX 0
|
||||
|
||||
/*
|
||||
* The qp group struct represents all the hw resources needed to present a ib_qp
|
||||
*/
|
||||
struct usnic_ib_qp_grp {
|
||||
struct ib_qp ibqp;
|
||||
enum ib_qp_state state;
|
||||
int grp_id;
|
||||
|
||||
struct usnic_fwd_dev *ufdev;
|
||||
short unsigned filter_cnt;
|
||||
struct usnic_fwd_filter filters[MAX_QP_GRP_FILTERS];
|
||||
struct list_head filter_hndls;
|
||||
enum usnic_transport_type transport;
|
||||
struct usnic_ib_ucontext *ctx;
|
||||
|
||||
struct usnic_vnic_res_chunk **res_chunk_list;
|
||||
|
||||
pid_t owner_pid;
|
||||
struct usnic_ib_vf *vf;
|
||||
struct list_head link;
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
struct kobject kobj;
|
||||
};
|
||||
|
||||
static const struct
|
||||
usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = {
|
||||
{ /*USNIC_TRANSPORT_UNKNOWN*/
|
||||
.resources = {
|
||||
{.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
|
||||
},
|
||||
},
|
||||
{ /*USNIC_TRANSPORT_ROCE_CUSTOM*/
|
||||
.resources = {
|
||||
{.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
|
||||
{.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
|
||||
{.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
|
||||
{.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);
|
||||
int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz);
|
||||
int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz);
|
||||
struct usnic_ib_qp_grp *
|
||||
usnic_ib_qp_grp_create(struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf,
|
||||
struct usnic_ib_pd *pd,
|
||||
struct usnic_vnic_res_spec *res_spec,
|
||||
enum usnic_transport_type transport);
|
||||
void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp);
|
||||
int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp,
|
||||
enum ib_qp_state new_state,
|
||||
struct usnic_fwd_filter *fwd_filter);
|
||||
struct usnic_vnic_res_chunk
|
||||
*usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp,
|
||||
enum usnic_vnic_res_type type);
|
||||
static inline
|
||||
struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp)
|
||||
{
|
||||
return container_of(ibqp, struct usnic_ib_qp_grp, ibqp);
|
||||
}
|
||||
#endif /* USNIC_IB_QP_GRP_H_ */
|
||||
351
drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
Normal file
351
drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
Normal file
@@ -0,0 +1,351 @@
|
||||
/*
|
||||
* 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/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
#include <rdma/ib_user_verbs.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
|
||||
#include "usnic_common_util.h"
|
||||
#include "usnic_ib.h"
|
||||
#include "usnic_ib_qp_grp.h"
|
||||
#include "usnic_vnic.h"
|
||||
#include "usnic_ib_verbs.h"
|
||||
#include "usnic_log.h"
|
||||
|
||||
#define UPDATE_PTR_LEFT(N, P, L) \
|
||||
do { \
|
||||
L -= (N); \
|
||||
P += (N); \
|
||||
} while (0)
|
||||
|
||||
static ssize_t usnic_ib_show_fw_ver(struct device *device,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
struct ethtool_drvinfo info;
|
||||
|
||||
mutex_lock(&us_ibdev->usdev_lock);
|
||||
us_ibdev->netdev->ethtool_ops->get_drvinfo(us_ibdev->netdev, &info);
|
||||
mutex_unlock(&us_ibdev->usdev_lock);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", info.fw_version);
|
||||
}
|
||||
|
||||
static ssize_t usnic_ib_show_board(struct device *device,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
unsigned short subsystem_device_id;
|
||||
|
||||
mutex_lock(&us_ibdev->usdev_lock);
|
||||
subsystem_device_id = us_ibdev->pdev->subsystem_device;
|
||||
mutex_unlock(&us_ibdev->usdev_lock);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%hu\n", subsystem_device_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Report the configuration for this PF
|
||||
*/
|
||||
static ssize_t
|
||||
usnic_ib_show_config(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
char *ptr;
|
||||
unsigned left;
|
||||
unsigned n;
|
||||
enum usnic_vnic_res_type res_type;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
|
||||
/* Buffer space limit is 1 page */
|
||||
ptr = buf;
|
||||
left = PAGE_SIZE;
|
||||
|
||||
mutex_lock(&us_ibdev->usdev_lock);
|
||||
if (atomic_read(&us_ibdev->vf_cnt.refcount) > 0) {
|
||||
char *busname;
|
||||
|
||||
/*
|
||||
* bus name seems to come with annoying prefix.
|
||||
* Remove it if it is predictable
|
||||
*/
|
||||
busname = us_ibdev->pdev->bus->name;
|
||||
if (strncmp(busname, "PCI Bus ", 8) == 0)
|
||||
busname += 8;
|
||||
|
||||
n = scnprintf(ptr, left,
|
||||
"%s: %s:%d.%d, %s, %pM, %u VFs\n Per VF:",
|
||||
us_ibdev->ib_dev.name,
|
||||
busname,
|
||||
PCI_SLOT(us_ibdev->pdev->devfn),
|
||||
PCI_FUNC(us_ibdev->pdev->devfn),
|
||||
netdev_name(us_ibdev->netdev),
|
||||
us_ibdev->mac,
|
||||
atomic_read(&us_ibdev->vf_cnt.refcount));
|
||||
UPDATE_PTR_LEFT(n, ptr, left);
|
||||
|
||||
for (res_type = USNIC_VNIC_RES_TYPE_EOL;
|
||||
res_type < USNIC_VNIC_RES_TYPE_MAX;
|
||||
res_type++) {
|
||||
if (us_ibdev->vf_res_cnt[res_type] == 0)
|
||||
continue;
|
||||
n = scnprintf(ptr, left, " %d %s%s",
|
||||
us_ibdev->vf_res_cnt[res_type],
|
||||
usnic_vnic_res_type_to_str(res_type),
|
||||
(res_type < (USNIC_VNIC_RES_TYPE_MAX - 1)) ?
|
||||
"," : "");
|
||||
UPDATE_PTR_LEFT(n, ptr, left);
|
||||
}
|
||||
n = scnprintf(ptr, left, "\n");
|
||||
UPDATE_PTR_LEFT(n, ptr, left);
|
||||
} else {
|
||||
n = scnprintf(ptr, left, "%s: no VFs\n",
|
||||
us_ibdev->ib_dev.name);
|
||||
UPDATE_PTR_LEFT(n, ptr, left);
|
||||
}
|
||||
mutex_unlock(&us_ibdev->usdev_lock);
|
||||
|
||||
return ptr - buf;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
usnic_ib_show_iface(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
||||
netdev_name(us_ibdev->netdev));
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
usnic_ib_show_max_vf(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n",
|
||||
atomic_read(&us_ibdev->vf_cnt.refcount));
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
usnic_ib_show_qp_per_vf(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
int qp_per_vf;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
qp_per_vf = max(us_ibdev->vf_res_cnt[USNIC_VNIC_RES_TYPE_WQ],
|
||||
us_ibdev->vf_res_cnt[USNIC_VNIC_RES_TYPE_RQ]);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE,
|
||||
"%d\n", qp_per_vf);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
usnic_ib_show_cq_per_vf(struct device *device, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
|
||||
us_ibdev = container_of(device, struct usnic_ib_dev, ib_dev.dev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%d\n",
|
||||
us_ibdev->vf_res_cnt[USNIC_VNIC_RES_TYPE_CQ]);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(fw_ver, S_IRUGO, usnic_ib_show_fw_ver, NULL);
|
||||
static DEVICE_ATTR(board_id, S_IRUGO, usnic_ib_show_board, NULL);
|
||||
static DEVICE_ATTR(config, S_IRUGO, usnic_ib_show_config, NULL);
|
||||
static DEVICE_ATTR(iface, S_IRUGO, usnic_ib_show_iface, NULL);
|
||||
static DEVICE_ATTR(max_vf, S_IRUGO, usnic_ib_show_max_vf, NULL);
|
||||
static DEVICE_ATTR(qp_per_vf, S_IRUGO, usnic_ib_show_qp_per_vf, NULL);
|
||||
static DEVICE_ATTR(cq_per_vf, S_IRUGO, usnic_ib_show_cq_per_vf, NULL);
|
||||
|
||||
static struct device_attribute *usnic_class_attributes[] = {
|
||||
&dev_attr_fw_ver,
|
||||
&dev_attr_board_id,
|
||||
&dev_attr_config,
|
||||
&dev_attr_iface,
|
||||
&dev_attr_max_vf,
|
||||
&dev_attr_qp_per_vf,
|
||||
&dev_attr_cq_per_vf,
|
||||
};
|
||||
|
||||
struct qpn_attribute {
|
||||
struct attribute attr;
|
||||
ssize_t (*show)(struct usnic_ib_qp_grp *, char *buf);
|
||||
};
|
||||
|
||||
/*
|
||||
* Definitions for supporting QPN entries in sysfs
|
||||
*/
|
||||
static ssize_t
|
||||
usnic_ib_qpn_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
|
||||
{
|
||||
struct usnic_ib_qp_grp *qp_grp;
|
||||
struct qpn_attribute *qpn_attr;
|
||||
|
||||
qp_grp = container_of(kobj, struct usnic_ib_qp_grp, kobj);
|
||||
qpn_attr = container_of(attr, struct qpn_attribute, attr);
|
||||
|
||||
return qpn_attr->show(qp_grp, buf);
|
||||
}
|
||||
|
||||
static const struct sysfs_ops usnic_ib_qpn_sysfs_ops = {
|
||||
.show = usnic_ib_qpn_attr_show
|
||||
};
|
||||
|
||||
#define QPN_ATTR_RO(NAME) \
|
||||
struct qpn_attribute qpn_attr_##NAME = __ATTR_RO(NAME)
|
||||
|
||||
static ssize_t context_show(struct usnic_ib_qp_grp *qp_grp, char *buf)
|
||||
{
|
||||
return scnprintf(buf, PAGE_SIZE, "0x%p\n", qp_grp->ctx);
|
||||
}
|
||||
|
||||
static ssize_t summary_show(struct usnic_ib_qp_grp *qp_grp, char *buf)
|
||||
{
|
||||
int i, j, n;
|
||||
int left;
|
||||
char *ptr;
|
||||
struct usnic_vnic_res_chunk *res_chunk;
|
||||
struct usnic_fwd_filter_hndl *default_filter_hndl;
|
||||
struct usnic_vnic_res *vnic_res;
|
||||
|
||||
left = PAGE_SIZE;
|
||||
ptr = buf;
|
||||
default_filter_hndl = list_first_entry(&qp_grp->filter_hndls,
|
||||
struct usnic_fwd_filter_hndl, link);
|
||||
|
||||
n = scnprintf(ptr, left,
|
||||
"QPN: %d State: (%s) PID: %u VF Idx: %hu Filter ID: 0x%x ",
|
||||
qp_grp->ibqp.qp_num,
|
||||
usnic_ib_qp_grp_state_to_string(qp_grp->state),
|
||||
qp_grp->owner_pid,
|
||||
usnic_vnic_get_index(qp_grp->vf->vnic),
|
||||
default_filter_hndl->id);
|
||||
UPDATE_PTR_LEFT(n, ptr, left);
|
||||
|
||||
for (i = 0; qp_grp->res_chunk_list[i]; i++) {
|
||||
res_chunk = qp_grp->res_chunk_list[i];
|
||||
for (j = 0; j < res_chunk->cnt; j++) {
|
||||
vnic_res = res_chunk->res[j];
|
||||
n = scnprintf(ptr, left, "%s[%d] ",
|
||||
usnic_vnic_res_type_to_str(vnic_res->type),
|
||||
vnic_res->vnic_idx);
|
||||
UPDATE_PTR_LEFT(n, ptr, left);
|
||||
}
|
||||
}
|
||||
|
||||
n = scnprintf(ptr, left, "\n");
|
||||
UPDATE_PTR_LEFT(n, ptr, left);
|
||||
|
||||
return ptr - buf;
|
||||
}
|
||||
|
||||
static QPN_ATTR_RO(context);
|
||||
static QPN_ATTR_RO(summary);
|
||||
|
||||
static struct attribute *usnic_ib_qpn_default_attrs[] = {
|
||||
&qpn_attr_context.attr,
|
||||
&qpn_attr_summary.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct kobj_type usnic_ib_qpn_type = {
|
||||
.sysfs_ops = &usnic_ib_qpn_sysfs_ops,
|
||||
.default_attrs = usnic_ib_qpn_default_attrs
|
||||
};
|
||||
|
||||
int usnic_ib_sysfs_register_usdev(struct usnic_ib_dev *us_ibdev)
|
||||
{
|
||||
int i;
|
||||
int err;
|
||||
for (i = 0; i < ARRAY_SIZE(usnic_class_attributes); ++i) {
|
||||
err = device_create_file(&us_ibdev->ib_dev.dev,
|
||||
usnic_class_attributes[i]);
|
||||
if (err) {
|
||||
usnic_err("Failed to create device file %d for %s eith err %d",
|
||||
i, us_ibdev->ib_dev.name, err);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* create kernel object for looking at individual QPs */
|
||||
kobject_get(&us_ibdev->ib_dev.dev.kobj);
|
||||
us_ibdev->qpn_kobj = kobject_create_and_add("qpn",
|
||||
&us_ibdev->ib_dev.dev.kobj);
|
||||
if (us_ibdev->qpn_kobj == NULL) {
|
||||
kobject_put(&us_ibdev->ib_dev.dev.kobj);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usnic_ib_sysfs_unregister_usdev(struct usnic_ib_dev *us_ibdev)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(usnic_class_attributes); ++i) {
|
||||
device_remove_file(&us_ibdev->ib_dev.dev,
|
||||
usnic_class_attributes[i]);
|
||||
}
|
||||
|
||||
kobject_put(us_ibdev->qpn_kobj);
|
||||
}
|
||||
|
||||
void usnic_ib_sysfs_qpn_add(struct usnic_ib_qp_grp *qp_grp)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
int err;
|
||||
|
||||
us_ibdev = qp_grp->vf->pf;
|
||||
|
||||
err = kobject_init_and_add(&qp_grp->kobj, &usnic_ib_qpn_type,
|
||||
kobject_get(us_ibdev->qpn_kobj),
|
||||
"%d", qp_grp->grp_id);
|
||||
if (err) {
|
||||
kobject_put(us_ibdev->qpn_kobj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void usnic_ib_sysfs_qpn_remove(struct usnic_ib_qp_grp *qp_grp)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
|
||||
us_ibdev = qp_grp->vf->pf;
|
||||
|
||||
kobject_put(&qp_grp->kobj);
|
||||
kobject_put(us_ibdev->qpn_kobj);
|
||||
}
|
||||
29
drivers/infiniband/hw/usnic/usnic_ib_sysfs.h
Normal file
29
drivers/infiniband/hw/usnic/usnic_ib_sysfs.h
Normal file
@@ -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_IB_SYSFS_H_
|
||||
#define USNIC_IB_SYSFS_H_
|
||||
|
||||
#include "usnic_ib.h"
|
||||
|
||||
int usnic_ib_sysfs_register_usdev(struct usnic_ib_dev *us_ibdev);
|
||||
void usnic_ib_sysfs_unregister_usdev(struct usnic_ib_dev *us_ibdev);
|
||||
void usnic_ib_sysfs_qpn_add(struct usnic_ib_qp_grp *qp_grp);
|
||||
void usnic_ib_sysfs_qpn_remove(struct usnic_ib_qp_grp *qp_grp);
|
||||
|
||||
#endif /* !USNIC_IB_SYSFS_H_ */
|
||||
736
drivers/infiniband/hw/usnic/usnic_ib_verbs.c
Normal file
736
drivers/infiniband/hw/usnic/usnic_ib_verbs.c
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user