From 11046e80488eb84164b26cecfc458a27d35893b2 Mon Sep 17 00:00:00 2001 From: hselasky Date: Wed, 15 Oct 2014 13:40:29 +0000 Subject: [PATCH] Update the OFED Linux compatibility layer and Mellanox hardware driver(s): - Properly name an inclusion guard - Fix compile warnings regarding unsigned enums - Add two new sysctl nodes - Remove all empty linux header files - Make an error printout more verbose - Use "mod_delayed_work()" instead of cancelling and starting a timeout. - Implement more Linux scatterlist functions. MFC after: 3 days Sponsored by: Mellanox Technologies --- sys/contrib/rdma/krping/krping.c | 1 - sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h | 1 - sys/ofed/drivers/infiniband/core/addr.c | 13 +- sys/ofed/drivers/infiniband/core/agent.c | 3 +- sys/ofed/drivers/infiniband/core/ucm.c | 1 - .../drivers/infiniband/core/uverbs_main.c | 1 - sys/ofed/drivers/infiniband/hw/mlx4/ah.c | 1 - .../infiniband/hw/mthca/mthca_config_reg.h | 2 +- .../infiniband/hw/mthca/mthca_memfree.c | 2 +- .../drivers/infiniband/hw/mthca/mthca_uar.c | 2 +- .../infiniband/ulp/ipoib/ipoib_ethtool.c | 1 - .../infiniband/ulp/ipoib/ipoib_verbs.c | 1 - sys/ofed/drivers/net/mlx4/Makefile | 1 - sys/ofed/drivers/net/mlx4/en_ethtool.c | 1 - sys/ofed/drivers/net/mlx4/en_frag.c | 192 --------------- sys/ofed/drivers/net/mlx4/en_netdev.c | 12 +- sys/ofed/drivers/net/mlx4/en_params.c | 0 sys/ofed/drivers/net/mlx4/en_selftest.c | 1 - sys/ofed/drivers/net/mlx4/en_tx.c | 2 +- sys/ofed/drivers/net/mlx4/pd.c | 2 +- sys/ofed/drivers/net/mlx4/xrcd.c | 69 ------ sys/ofed/include/asm/page.h | 35 --- sys/ofed/include/linux/completion.h | 4 +- sys/ofed/include/linux/etherdevice.h | 2 +- sys/ofed/include/linux/ethtool.h | 32 --- sys/ofed/include/linux/inet.h | 32 --- sys/ofed/include/linux/linux_compat.c | 6 +- sys/ofed/include/linux/mlx4/device.h | 2 + sys/ofed/include/linux/mlx4/driver.h | 2 +- sys/ofed/include/linux/mount.h | 34 --- sys/ofed/include/linux/netdevice.h | 1 - sys/ofed/include/linux/scatterlist.h | 227 ++++++++++++++++++ sys/ofed/include/linux/vmalloc.h | 2 +- sys/ofed/include/rdma/ib_addr.h | 1 - sys/ofed/include/rdma/ib_smi.h | 1 + sys/ofed/include/rdma/ib_user_cm.h | 1 + 36 files changed, 264 insertions(+), 427 deletions(-) delete mode 100644 sys/ofed/drivers/net/mlx4/en_frag.c delete mode 100644 sys/ofed/drivers/net/mlx4/en_params.c delete mode 100644 sys/ofed/drivers/net/mlx4/xrcd.c delete mode 100644 sys/ofed/include/asm/page.h delete mode 100644 sys/ofed/include/linux/ethtool.h delete mode 100644 sys/ofed/include/linux/inet.h delete mode 100644 sys/ofed/include/linux/mount.h diff --git a/sys/contrib/rdma/krping/krping.c b/sys/contrib/rdma/krping/krping.c index 733dd8ae1d87..228063605728 100644 --- a/sys/contrib/rdma/krping/krping.c +++ b/sys/contrib/rdma/krping/krping.c @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include diff --git a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h index 0201a79b7bcb..245e045240b9 100644 --- a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h +++ b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/sys/ofed/drivers/infiniband/core/addr.c b/sys/ofed/drivers/infiniband/core/addr.c index f454ffb65876..f608244da9a5 100644 --- a/sys/ofed/drivers/infiniband/core/addr.c +++ b/sys/ofed/drivers/infiniband/core/addr.c @@ -35,10 +35,15 @@ #include #include +#include #include +#include +#include #include #include #include +#include + MODULE_AUTHOR("Sean Hefty"); MODULE_DESCRIPTION("IB Address Translation"); @@ -189,13 +194,11 @@ static void set_timeout(unsigned long time) { unsigned long delay; - cancel_delayed_work(&work); - delay = time - jiffies; if ((long)delay <= 0) delay = 1; - queue_delayed_work(addr_wq, &work, delay); + mod_delayed_work(addr_wq, &work, delay); } static void queue_req(struct addr_req *req) @@ -620,7 +623,7 @@ static struct notifier_block nb = { .notifier_call = netevent_callback }; -static int addr_init(void) +static int __init addr_init(void) { INIT_DELAYED_WORK(&work, process_req); addr_wq = create_singlethread_workqueue("ib_addr"); @@ -631,7 +634,7 @@ static int addr_init(void) return 0; } -static void addr_cleanup(void) +static void __exit addr_cleanup(void) { unregister_netevent_notifier(&nb); destroy_workqueue(addr_wq); diff --git a/sys/ofed/drivers/infiniband/core/agent.c b/sys/ofed/drivers/infiniband/core/agent.c index 91916a8d5de4..2bc7f5af64f4 100644 --- a/sys/ofed/drivers/infiniband/core/agent.c +++ b/sys/ofed/drivers/infiniband/core/agent.c @@ -101,7 +101,8 @@ void agent_send_response(struct ib_mad *mad, struct ib_grh *grh, agent = port_priv->agent[qpn]; ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num); if (IS_ERR(ah)) { - printk(KERN_ERR SPFX "ib_create_ah_from_wc error\n"); + printk(KERN_ERR SPFX "ib_create_ah_from_wc error %ld\n", + PTR_ERR(ah)); return; } diff --git a/sys/ofed/drivers/infiniband/core/ucm.c b/sys/ofed/drivers/infiniband/core/ucm.c index 5494da3b92a5..b912ebeb427a 100644 --- a/sys/ofed/drivers/infiniband/core/ucm.c +++ b/sys/ofed/drivers/infiniband/core/ucm.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/sys/ofed/drivers/infiniband/core/uverbs_main.c b/sys/ofed/drivers/infiniband/core/uverbs_main.c index c51b810d881a..30b925915ea9 100644 --- a/sys/ofed/drivers/infiniband/core/uverbs_main.c +++ b/sys/ofed/drivers/infiniband/core/uverbs_main.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/sys/ofed/drivers/infiniband/hw/mlx4/ah.c b/sys/ofed/drivers/infiniband/hw/mlx4/ah.c index 47c9aa0c512d..fe35e62d4ae5 100644 --- a/sys/ofed/drivers/infiniband/hw/mlx4/ah.c +++ b/sys/ofed/drivers/infiniband/hw/mlx4/ah.c @@ -38,7 +38,6 @@ #include #include -#include #include #include "mlx4_ib.h" diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h b/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h index 75671f75cac4..43c08943668c 100644 --- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h +++ b/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h @@ -34,7 +34,7 @@ #ifndef MTHCA_CONFIG_REG_H #define MTHCA_CONFIG_REG_H -#include +#include #define MTHCA_HCR_BASE 0x80680 #define MTHCA_HCR_SIZE 0x0001c diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c index cc5c867d6cc8..0cdebaf17268 100644 --- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -36,7 +36,7 @@ #include #include -#include +#include #include "mthca_memfree.h" #include "mthca_dev.h" diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c index ca5900c96fcf..5c9ad23de8d9 100644 --- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c +++ b/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c @@ -30,7 +30,7 @@ * SOFTWARE. */ -#include /* PAGE_SHIFT */ +#include #include "mthca_dev.h" #include "mthca_memfree.h" diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c index ec52712db235..04819a9ee99b 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c @@ -31,7 +31,6 @@ */ #include -#include #include #include "ipoib.h" diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c index fb9a27abbbcc..214f81afaaff 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c @@ -32,7 +32,6 @@ */ #include "ipoib.h" -#include int ipoib_mcast_attach(struct ipoib_dev_priv *priv, u16 mlid, union ib_gid *mgid, int set_qkey) { diff --git a/sys/ofed/drivers/net/mlx4/Makefile b/sys/ofed/drivers/net/mlx4/Makefile index d6fe77534817..dc0e2a374112 100644 --- a/sys/ofed/drivers/net/mlx4/Makefile +++ b/sys/ofed/drivers/net/mlx4/Makefile @@ -31,4 +31,3 @@ opt_inet6.h: .include CFLAGS+= -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS} - diff --git a/sys/ofed/drivers/net/mlx4/en_ethtool.c b/sys/ofed/drivers/net/mlx4/en_ethtool.c index 6569a535f412..3ebeaf4bee5b 100644 --- a/sys/ofed/drivers/net/mlx4/en_ethtool.c +++ b/sys/ofed/drivers/net/mlx4/en_ethtool.c @@ -32,7 +32,6 @@ */ #include -#include #include #include #include diff --git a/sys/ofed/drivers/net/mlx4/en_frag.c b/sys/ofed/drivers/net/mlx4/en_frag.c deleted file mode 100644 index c8429e4b12d3..000000000000 --- a/sys/ofed/drivers/net/mlx4/en_frag.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 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 "opt_inet.h" -#include "mlx4_en.h" - -#ifdef INET - -#include -#include -#include - -static struct mlx4_en_ipfrag *find_session(struct mlx4_en_rx_ring *ring, - struct ip *iph) -{ - struct mlx4_en_ipfrag *session; - int i; - - for (i = 0; i < MLX4_EN_NUM_IPFRAG_SESSIONS; i++) { - session = &ring->ipfrag[i]; - if (session->fragments == NULL) - continue; - if (session->daddr == iph->ip_dst.s_addr && - session->saddr == iph->ip_src.s_addr && - session->id == iph->ip_id && - session->protocol == iph->ip_p) { - return session; - } - } - return NULL; -} - -static struct mlx4_en_ipfrag *start_session(struct mlx4_en_rx_ring *ring, - struct ip *iph) -{ - struct mlx4_en_ipfrag *session; - int index = -1; - int i; - - for (i = 0; i < MLX4_EN_NUM_IPFRAG_SESSIONS; i++) { - if (ring->ipfrag[i].fragments == NULL) { - index = i; - break; - } - } - if (index < 0) - return NULL; - - session = &ring->ipfrag[index]; - - return session; -} - - -static void flush_session(struct mlx4_en_priv *priv, - struct mlx4_en_ipfrag *session, - u16 more) -{ - struct mbuf *mb = session->fragments; - struct ip *iph = mb->m_pkthdr.PH_loc.ptr; - struct net_device *dev = mb->m_pkthdr.rcvif; - - /* Update IP length and checksum */ - iph->ip_len = htons(session->total_len); - iph->ip_off = htons(more | (session->offset >> 3)); - iph->ip_sum = 0; - iph->ip_sum = in_cksum_skip(mb, iph->ip_hl * 4, - (char *)iph - mb->m_data); - - dev->if_input(dev, mb); - session->fragments = NULL; - session->last = NULL; -} - - -static inline void frag_append(struct mlx4_en_priv *priv, - struct mlx4_en_ipfrag *session, - struct mbuf *mb, - unsigned int data_len) -{ - struct mbuf *parent = session->fragments; - - /* Update mb bookkeeping */ - parent->m_pkthdr.len += data_len; - session->total_len += data_len; - - m_adj(mb, mb->m_pkthdr.len - data_len); - - session->last->m_next = mb; - for (; mb->m_next != NULL; mb = mb->m_next); - session->last = mb; -} - -int mlx4_en_rx_frags(struct mlx4_en_priv *priv, struct mlx4_en_rx_ring *ring, - struct mbuf *mb, struct mlx4_cqe *cqe) -{ - struct mlx4_en_ipfrag *session; - struct ip *iph; - u16 ip_len; - u16 ip_hlen; - int data_len; - u16 offset; - - iph = (struct ip *)(mtod(mb, char *) + ETHER_HDR_LEN); - mb->m_pkthdr.PH_loc.ptr = iph; - ip_len = ntohs(iph->ip_len); - ip_hlen = iph->ip_hl * 4; - data_len = ip_len - ip_hlen; - offset = ntohs(iph->ip_off); - offset &= IP_OFFMASK; - offset <<= 3; - - session = find_session(ring, iph); - if (unlikely(in_cksum_skip(mb, ip_hlen, (char *)iph - mb->m_data))) { - if (session) - flush_session(priv, session, IP_MF); - return -EINVAL; - } - if (session) { - if (unlikely(session->offset + session->total_len != - offset + ip_hlen || - session->total_len + mb->m_pkthdr.len > 65536)) { - flush_session(priv, session, IP_MF); - goto new_session; - } - frag_append(priv, session, mb, data_len); - } else { -new_session: - session = start_session(ring, iph); - if (unlikely(!session)) - return -ENOSPC; - - session->fragments = mb; - session->daddr = iph->ip_dst.s_addr; - session->saddr = iph->ip_src.s_addr; - session->id = iph->ip_id; - session->protocol = iph->ip_p; - session->total_len = ip_len; - session->offset = offset; - for (; mb->m_next != NULL; mb = mb->m_next); - session->last = mb; - } - if (!(ntohs(iph->ip_off) & IP_MF)) - flush_session(priv, session, 0); - - return 0; -} - - -void mlx4_en_flush_frags(struct mlx4_en_priv *priv, - struct mlx4_en_rx_ring *ring) -{ - struct mlx4_en_ipfrag *session; - int i; - - for (i = 0; i < MLX4_EN_NUM_IPFRAG_SESSIONS; i++) { - session = &ring->ipfrag[i]; - if (session->fragments) - flush_session(priv, session, IP_MF); - } -} -#endif diff --git a/sys/ofed/drivers/net/mlx4/en_netdev.c b/sys/ofed/drivers/net/mlx4/en_netdev.c index e76da65f288e..d7d63d351b82 100644 --- a/sys/ofed/drivers/net/mlx4/en_netdev.c +++ b/sys/ofed/drivers/net/mlx4/en_netdev.c @@ -2335,9 +2335,11 @@ static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv) struct sysctl_oid_list *node_list; struct sysctl_oid *coal; struct sysctl_oid_list *coal_list; + const char *pnameunit; dev = priv->dev; ctx = &priv->conf_ctx; + pnameunit = device_get_nameunit(priv->mdev->pdev->dev.bsddev); sysctl_ctx_init(ctx); priv->sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw), @@ -2350,10 +2352,10 @@ static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv) CTLFLAG_RW, &priv->msg_enable, 0, "Driver message enable bitfield"); SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "rx_rings", - CTLTYPE_INT | CTLFLAG_RD, &priv->rx_ring_num, 0, + CTLFLAG_RD, &priv->rx_ring_num, 0, "Number of receive rings"); SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "tx_rings", - CTLTYPE_INT | CTLFLAG_RD, &priv->tx_ring_num, 0, + CTLFLAG_RD, &priv->tx_ring_num, 0, "Number of transmit rings"); SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "rx_size", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, @@ -2367,6 +2369,12 @@ static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv) SYSCTL_ADD_PROC(ctx, node_list, OID_AUTO, "rx_ppp", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, priv, 0, mlx4_en_set_rx_ppp, "I", "RX Per-priority pause"); + SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "port_num", + CTLFLAG_RD, &priv->port, 0, + "Port Number"); + SYSCTL_ADD_STRING(ctx, node_list, OID_AUTO, "device_name", + CTLFLAG_RD, __DECONST(void *, pnameunit), 0, + "PCI device name"); /* Add coalescer configuration. */ coal = SYSCTL_ADD_NODE(ctx, node_list, OID_AUTO, diff --git a/sys/ofed/drivers/net/mlx4/en_params.c b/sys/ofed/drivers/net/mlx4/en_params.c deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sys/ofed/drivers/net/mlx4/en_selftest.c b/sys/ofed/drivers/net/mlx4/en_selftest.c index 2a28315d5965..fb13bd691660 100644 --- a/sys/ofed/drivers/net/mlx4/en_selftest.c +++ b/sys/ofed/drivers/net/mlx4/en_selftest.c @@ -32,7 +32,6 @@ */ #include -#include #include #include #include diff --git a/sys/ofed/drivers/net/mlx4/en_tx.c b/sys/ofed/drivers/net/mlx4/en_tx.c index 94ac8c547d2d..d1931558bcc9 100644 --- a/sys/ofed/drivers/net/mlx4/en_tx.c +++ b/sys/ofed/drivers/net/mlx4/en_tx.c @@ -31,7 +31,7 @@ * */ -#include +#include #include #include #include diff --git a/sys/ofed/drivers/net/mlx4/pd.c b/sys/ofed/drivers/net/mlx4/pd.c index 5162a47d5b48..89a8854699ac 100644 --- a/sys/ofed/drivers/net/mlx4/pd.c +++ b/sys/ofed/drivers/net/mlx4/pd.c @@ -35,7 +35,7 @@ #include #include -#include +#include #include "mlx4.h" #include "icm.h" diff --git a/sys/ofed/drivers/net/mlx4/xrcd.c b/sys/ofed/drivers/net/mlx4/xrcd.c deleted file mode 100644 index 6e3c34168d7d..000000000000 --- a/sys/ofed/drivers/net/mlx4/xrcd.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007 Mellanox Technologies. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 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 - -#include "mlx4.h" - -int mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn) -{ - struct mlx4_priv *priv = mlx4_priv(dev); - - *xrcdn = mlx4_bitmap_alloc(&priv->xrcd_bitmap); - if (*xrcdn == -1) - return -ENOMEM; - - return 0; -} -EXPORT_SYMBOL_GPL(mlx4_xrcd_alloc); - -void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn) -{ - mlx4_bitmap_free(&mlx4_priv(dev)->xrcd_bitmap, xrcdn); -} -EXPORT_SYMBOL_GPL(mlx4_xrcd_free); - -int __devinit mlx4_init_xrcd_table(struct mlx4_dev *dev) -{ - struct mlx4_priv *priv = mlx4_priv(dev); - - return mlx4_bitmap_init(&priv->xrcd_bitmap, (1 << 16), - (1 << 16) - 1, dev->caps.reserved_xrcds + 1, 0); -} - -void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev) -{ - mlx4_bitmap_cleanup(&mlx4_priv(dev)->xrcd_bitmap); -} - - diff --git a/sys/ofed/include/asm/page.h b/sys/ofed/include/asm/page.h deleted file mode 100644 index e93dc964988e..000000000000 --- a/sys/ofed/include/asm/page.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2010 Isilon Systems, Inc. - * Copyright (c) 2010 iX Systems, Inc. - * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice unmodified, this list of conditions, and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ASM_PAGE_H_ -#define _ASM_PAGE_H_ - -#include - -#endif /*_ASM_PAGE_H_*/ diff --git a/sys/ofed/include/linux/completion.h b/sys/ofed/include/linux/completion.h index 1ef23ea0009b..df4aec3595e4 100644 --- a/sys/ofed/include/linux/completion.h +++ b/sys/ofed/include/linux/completion.h @@ -27,8 +27,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _FBSD_COMPLETION_H_ -#define _FBSD_COMPLETION_H_ +#ifndef _LINUX_COMPLETION_H_ +#define _LINUX_COMPLETION_H_ #include diff --git a/sys/ofed/include/linux/etherdevice.h b/sys/ofed/include/linux/etherdevice.h index 43bc1f29dacd..7d1114501ce7 100644 --- a/sys/ofed/include/linux/etherdevice.h +++ b/sys/ofed/include/linux/etherdevice.h @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014 Mellanox Technologies, Ltd. All rights reserved. * diff --git a/sys/ofed/include/linux/ethtool.h b/sys/ofed/include/linux/ethtool.h deleted file mode 100644 index 016b1a5445e5..000000000000 --- a/sys/ofed/include/linux/ethtool.h +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * Copyright (c) 2010 Isilon Systems, Inc. - * Copyright (c) 2010 iX Systems, Inc. - * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013 Mellanox Technologies, Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice unmodified, this list of conditions, and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _LINUX_ETHTOOL_H_ -#define _LINUX_ETHTOOL_H_ - -#endif /* _LINUX_ETHTOOL_H_ */ diff --git a/sys/ofed/include/linux/inet.h b/sys/ofed/include/linux/inet.h deleted file mode 100644 index cca8b60860af..000000000000 --- a/sys/ofed/include/linux/inet.h +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * Copyright (c) 2010 Isilon Systems, Inc. - * Copyright (c) 2010 iX Systems, Inc. - * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice unmodified, this list of conditions, and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LINUX_INET_H_ -#define _LINUX_INET_H_ -#endif /* _LINUX_INET_H_ */ diff --git a/sys/ofed/include/linux/linux_compat.c b/sys/ofed/include/linux/linux_compat.c index c2fb4d7d7abf..39dfeaf7a172 100644 --- a/sys/ofed/include/linux/linux_compat.c +++ b/sys/ofed/include/linux/linux_compat.c @@ -588,15 +588,15 @@ struct fileops linuxfileops = { .fo_read = linux_file_read, .fo_write = invfo_rdwr, .fo_truncate = invfo_truncate, - .fo_ioctl = linux_file_ioctl, - .fo_poll = linux_file_poll, .fo_kqfilter = invfo_kqfilter, .fo_stat = linux_file_stat, + .fo_fill_kinfo = linux_file_fill_kinfo, + .fo_poll = linux_file_poll, .fo_close = linux_file_close, + .fo_ioctl = linux_file_ioctl, .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, - .fo_fill_kinfo = linux_file_fill_kinfo, }; /* diff --git a/sys/ofed/include/linux/mlx4/device.h b/sys/ofed/include/linux/mlx4/device.h index c1095a51db43..fa1631e7bf59 100644 --- a/sys/ofed/include/linux/mlx4/device.h +++ b/sys/ofed/include/linux/mlx4/device.h @@ -1036,6 +1036,7 @@ enum mlx4_net_trans_rule_id { MLX4_NET_TRANS_RULE_ID_TCP, MLX4_NET_TRANS_RULE_ID_UDP, MLX4_NET_TRANS_RULE_NUM, /* should be last */ + MLX4_NET_TRANS_RULE_DUMMY = -1, /* force enum to be signed */ }; extern const u16 __sw_id_hw[]; @@ -1058,6 +1059,7 @@ enum mlx4_net_trans_promisc_mode { MLX4_FS_UC_SNIFFER, MLX4_FS_MC_SNIFFER, MLX4_FS_MODE_NUM, /* should be last */ + MLX4_FS_MODE_DUMMY = -1, /* force enum to be signed */ }; struct mlx4_spec_eth { diff --git a/sys/ofed/include/linux/mlx4/driver.h b/sys/ofed/include/linux/mlx4/driver.h index 2a7fd21ed4d9..b090c01a48d5 100644 --- a/sys/ofed/include/linux/mlx4/driver.h +++ b/sys/ofed/include/linux/mlx4/driver.h @@ -121,7 +121,7 @@ void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, #ifndef ETH_ALEN #define ETH_ALEN 6 #endif -static inline u64 mlx4_mac_to_u64(u8 *addr) +static inline u64 mlx4_mac_to_u64(const u8 *addr) { u64 mac = 0; int i; diff --git a/sys/ofed/include/linux/mount.h b/sys/ofed/include/linux/mount.h deleted file mode 100644 index a4451398c62d..000000000000 --- a/sys/ofed/include/linux/mount.h +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2010 Isilon Systems, Inc. - * Copyright (c) 2010 iX Systems, Inc. - * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice unmodified, this list of conditions, and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LINUX_MOUNT_H_ -#define _LINUX_MOUNT_H_ - - -#endif /* _LINUX_MOUNT_H_ */ diff --git a/sys/ofed/include/linux/netdevice.h b/sys/ofed/include/linux/netdevice.h index f6165f5f75ef..a18070e0e05b 100644 --- a/sys/ofed/include/linux/netdevice.h +++ b/sys/ofed/include/linux/netdevice.h @@ -40,7 +40,6 @@ #include #include -#include #include #include #include diff --git a/sys/ofed/include/linux/scatterlist.h b/sys/ofed/include/linux/scatterlist.h index eada862e6bc3..595e2e9c8d8b 100644 --- a/sys/ofed/include/linux/scatterlist.h +++ b/sys/ofed/include/linux/scatterlist.h @@ -31,6 +31,21 @@ #define _LINUX_SCATTERLIST_H_ #include +#include + +/* + * SG table design. + * + * If flags bit 0 is set, then the sg field contains a pointer to the next sg + * table list. Otherwise the next entry is at sg + 1, can be determined using + * the sg_is_chain() function. + * + * If flags bit 1 is set, then this sg entry is the last element in a list, + * can be determined using the sg_is_last() function. + * + * See sg_next(). + * + */ struct scatterlist { union { @@ -49,6 +64,12 @@ struct sg_table { unsigned int orig_nents; /* original size of list */ }; +/* + * Maximum number of entries that will be allocated in one piece, if + * a list larger than this is required then chaining will be utilized. + */ +#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist)) + #define sg_dma_address(sg) (sg)->address #define sg_dma_len(sg) (sg)->length #define sg_page(sg) (sg)->sl_un.page @@ -99,6 +120,212 @@ sg_phys(struct scatterlist *sg) return sg_page(sg)->phys_addr + sg->offset; } +/** + * sg_chain - Chain two sglists together + * @prv: First scatterlist + * @prv_nents: Number of entries in prv + * @sgl: Second scatterlist + * + * Description: + * Links @prv@ and @sgl@ together, to form a longer scatterlist. + * + **/ +static inline void +sg_chain(struct scatterlist *prv, unsigned int prv_nents, + struct scatterlist *sgl) +{ +/* + * offset and length are unused for chain entry. Clear them. + */ + struct scatterlist *sg = &prv[prv_nents - 1]; + + sg->offset = 0; + sg->length = 0; + + /* + * Indicate a link pointer, and set the link to the second list. + */ + sg->flags = SG_CHAIN; + sg->sl_un.sg = sgl; +} + +/** + * sg_mark_end - Mark the end of the scatterlist + * @sg: SG entryScatterlist + * + * Description: + * Marks the passed in sg entry as the termination point for the sg + * table. A call to sg_next() on this entry will return NULL. + * + **/ +static inline void sg_mark_end(struct scatterlist *sg) +{ + sg->flags = SG_END; +} + +/** + * __sg_free_table - Free a previously mapped sg table + * @table: The sg table header to use + * @max_ents: The maximum number of entries per single scatterlist + * + * Description: + * Free an sg table previously allocated and setup with + * __sg_alloc_table(). The @max_ents value must be identical to + * that previously used with __sg_alloc_table(). + * + **/ +static inline void +__sg_free_table(struct sg_table *table, unsigned int max_ents) +{ + struct scatterlist *sgl, *next; + + if (unlikely(!table->sgl)) + return; + + sgl = table->sgl; + while (table->orig_nents) { + unsigned int alloc_size = table->orig_nents; + unsigned int sg_size; + + /* + * If we have more than max_ents segments left, + * then assign 'next' to the sg table after the current one. + * sg_size is then one less than alloc size, since the last + * element is the chain pointer. + */ + if (alloc_size > max_ents) { + next = sgl[max_ents - 1].sl_un.sg; + alloc_size = max_ents; + sg_size = alloc_size - 1; + } else { + sg_size = alloc_size; + next = NULL; + } + + table->orig_nents -= sg_size; + kfree(sgl); + sgl = next; + } + + table->sgl = NULL; +} + +/** + * sg_free_table - Free a previously allocated sg table + * @table: The mapped sg table header + * + **/ +static inline void +sg_free_table(struct sg_table *table) +{ + __sg_free_table(table, SG_MAX_SINGLE_ALLOC); +} + +/** + * __sg_alloc_table - Allocate and initialize an sg table with given allocator + * @table: The sg table header to use + * @nents: Number of entries in sg list + * @max_ents: The maximum number of entries the allocator returns per call + * @gfp_mask: GFP allocation mask + * + * Description: + * This function returns a @table @nents long. The allocator is + * defined to return scatterlist chunks of maximum size @max_ents. + * Thus if @nents is bigger than @max_ents, the scatterlists will be + * chained in units of @max_ents. + * + * Notes: + * If this function returns non-0 (eg failure), the caller must call + * __sg_free_table() to cleanup any leftover allocations. + * + **/ +static inline int +__sg_alloc_table(struct sg_table *table, unsigned int nents, + unsigned int max_ents, gfp_t gfp_mask) +{ + struct scatterlist *sg, *prv; + unsigned int left; + + memset(table, 0, sizeof(*table)); + + if (nents == 0) + return -EINVAL; + left = nents; + prv = NULL; + do { + unsigned int sg_size, alloc_size = left; + + if (alloc_size > max_ents) { + alloc_size = max_ents; + sg_size = alloc_size - 1; + } else + sg_size = alloc_size; + + left -= sg_size; + + sg = kmalloc(alloc_size * sizeof(struct scatterlist), gfp_mask); + if (unlikely(!sg)) { + /* + * Adjust entry count to reflect that the last + * entry of the previous table won't be used for + * linkage. Without this, sg_kfree() may get + * confused. + */ + if (prv) + table->nents = ++table->orig_nents; + + return -ENOMEM; + } + + sg_init_table(sg, alloc_size); + table->nents = table->orig_nents += sg_size; + + /* + * If this is the first mapping, assign the sg table header. + * If this is not the first mapping, chain previous part. + */ + if (prv) + sg_chain(prv, max_ents, sg); + else + table->sgl = sg; + + /* + * If no more entries after this one, mark the end + */ + if (!left) + sg_mark_end(&sg[sg_size - 1]); + + prv = sg; + } while (left); + + return 0; +} + +/** + * sg_alloc_table - Allocate and initialize an sg table + * @table: The sg table header to use + * @nents: Number of entries in sg list + * @gfp_mask: GFP allocation mask + * + * Description: + * Allocate and initialize an sg table. If @nents@ is larger than + * SG_MAX_SINGLE_ALLOC a chained sg table will be setup. + * + **/ + +static inline int +sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask) +{ + int ret; + + ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC, + gfp_mask); + if (unlikely(ret)) + __sg_free_table(table, SG_MAX_SINGLE_ALLOC); + + return ret; +} + #define for_each_sg(sglist, sg, sgmax, _itr) \ for (_itr = 0, sg = (sglist); _itr < (sgmax); _itr++, sg = sg_next(sg)) diff --git a/sys/ofed/include/linux/vmalloc.h b/sys/ofed/include/linux/vmalloc.h index 1cb208ba3cb2..2629d3833bf6 100644 --- a/sys/ofed/include/linux/vmalloc.h +++ b/sys/ofed/include/linux/vmalloc.h @@ -30,7 +30,7 @@ #ifndef _LINUX_VMALLOC_H_ #define _LINUX_VMALLOC_H_ -#include +#include #define VM_MAP 0x0000 #define PAGE_KERNEL 0x0000 diff --git a/sys/ofed/include/rdma/ib_addr.h b/sys/ofed/include/rdma/ib_addr.h index a1f95dd0016e..b71151004347 100644 --- a/sys/ofed/include/rdma/ib_addr.h +++ b/sys/ofed/include/rdma/ib_addr.h @@ -41,7 +41,6 @@ #include #include #include -#include #include struct rdma_addr_client { diff --git a/sys/ofed/include/rdma/ib_smi.h b/sys/ofed/include/rdma/ib_smi.h index 98b9086d769a..973c9a4efec8 100644 --- a/sys/ofed/include/rdma/ib_smi.h +++ b/sys/ofed/include/rdma/ib_smi.h @@ -38,6 +38,7 @@ #define IB_SMI_H #include +#include #define IB_SMP_DATA_SIZE 64 #define IB_SMP_MAX_PATH_HOPS 64 diff --git a/sys/ofed/include/rdma/ib_user_cm.h b/sys/ofed/include/rdma/ib_user_cm.h index bd3d380781e0..f79014aa28f9 100644 --- a/sys/ofed/include/rdma/ib_user_cm.h +++ b/sys/ofed/include/rdma/ib_user_cm.h @@ -34,6 +34,7 @@ #ifndef IB_USER_CM_H #define IB_USER_CM_H +#include #include #define IB_USER_CM_ABI_VERSION 5