Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH V2 for-next 4/8] net: hns: delete repeat read fbd num after while
From: Salil Mehta @ 2016-09-29 17:09 UTC (permalink / raw)
  To: dledford
  Cc: salil.mehta, yisen.zhuang, xavier.huwei, oulijun, mehta.salil.lnk,
	linux-rdma, netdev, linux-kernel, linuxarm, Daode Huang
In-Reply-To: <20160929170916.631972-1-salil.mehta@huawei.com>

From: Daode Huang <huangdaode@hisilicon.com>

Because we handle the received packets after napi, so delete the checking
before submitting. It delete the code of read the fbd number register,
which reduces the cpu usages while receiving packets

Signed-off-by: Daode Huang <huangdaode@hisilicon.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index e6bfc51..09ed237 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -760,7 +760,7 @@ static int hns_nic_rx_poll_one(struct hns_nic_ring_data *ring_data,
 {
 	struct hnae_ring *ring = ring_data->ring;
 	struct sk_buff *skb;
-	int num, bnum, ex_num;
+	int num, bnum;
 #define RCB_NOF_ALLOC_RX_BUFF_ONCE 16
 	int recv_pkts, recv_bds, clean_count, err;
 	int unused_count = hns_desc_unused(ring);
@@ -770,7 +770,7 @@ static int hns_nic_rx_poll_one(struct hns_nic_ring_data *ring_data,
 
 	recv_pkts = 0, recv_bds = 0, clean_count = 0;
 	num -= unused_count;
-recv:
+
 	while (recv_pkts < budget && recv_bds < num) {
 		/* reuse or realloc buffers */
 		if (clean_count + unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
@@ -798,17 +798,6 @@ recv:
 		recv_pkts++;
 	}
 
-	/* make all data has been write before submit */
-	if (recv_pkts < budget) {
-		ex_num = readl_relaxed(ring->io_base + RCB_REG_FBDNUM);
-		ex_num -= unused_count;
-		if (ex_num > clean_count) {
-			num += ex_num - clean_count;
-			rmb(); /*complete read rx ring bd number*/
-			goto recv;
-		}
-	}
-
 out:
 	/* make all data has been write before submit */
 	if (clean_count + unused_count > 0)
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH V2 for-next 5/8] net: hns: fix port not available after testing loopback
From: Salil Mehta @ 2016-09-29 17:09 UTC (permalink / raw)
  To: dledford
  Cc: salil.mehta, yisen.zhuang, xavier.huwei, oulijun, mehta.salil.lnk,
	linux-rdma, netdev, linux-kernel, linuxarm, Kejian Yan
In-Reply-To: <20160929170916.631972-1-salil.mehta@huawei.com>

From: Kejian Yan <yankejian@huawei.com>

After running command "ethtool -t eth0", eth0 can not be connected to
network. It is caused by the changing the inner loopback register and
this register cannot be changed when hns connected to network. The
routine of setting this register needs to be removed and using promisc
mode to let the packet looped back pass by dsaf mode.

Reported-by: Jun He <hjat2005@huawei.com>
Signed-off-by: Kejian Yan <yankejian@huawei.com>
Reviewed-by: Yisen Zhaung <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c  |    3 ---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |   10 ----------
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h |    1 -
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c   |    7 +++++++
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index e28d960..e0f9cdc 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -678,9 +678,6 @@ static int hns_ae_config_loopback(struct hnae_handle *handle,
 		ret = -EINVAL;
 	}
 
-	if (!ret)
-		hns_dsaf_set_inner_lb(mac_cb->dsaf_dev, mac_cb->mac_id, en);
-
 	return ret;
 }
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 9283bc6..827d8fb 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -768,16 +768,6 @@ void hns_dsaf_set_promisc_mode(struct dsaf_device *dsaf_dev, u32 en)
 				 DSAF_CFG_MIX_MODE_S, !!en);
 }
 
-void hns_dsaf_set_inner_lb(struct dsaf_device *dsaf_dev, u32 mac_id, u32 en)
-{
-	if (AE_IS_VER1(dsaf_dev->dsaf_ver) ||
-	    dsaf_dev->mac_cb[mac_id]->mac_type == HNAE_PORT_DEBUG)
-		return;
-
-	dsaf_set_dev_bit(dsaf_dev, DSAFV2_SERDES_LBK_0_REG + 4 * mac_id,
-			 DSAFV2_SERDES_LBK_EN_B, !!en);
-}
-
 /**
  * hns_dsaf_tbl_stat_en - tbl
  * @dsaf_id: dsa fabric id
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
index 35df187..c494fc5 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
@@ -466,6 +466,5 @@ void hns_dsaf_get_rx_mac_pause_en(struct dsaf_device *dsaf_dev, int mac_id,
 				  u32 *en);
 int hns_dsaf_set_rx_mac_pause_en(struct dsaf_device *dsaf_dev, int mac_id,
 				 u32 en);
-void hns_dsaf_set_inner_lb(struct dsaf_device *dsaf_dev, u32 mac_id, u32 en);
 
 #endif /* __HNS_DSAF_MAIN_H__ */
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
index ab33487..fa91ce3 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
@@ -342,6 +342,13 @@ static int __lb_setup(struct net_device *ndev,
 		break;
 	}
 
+	if (!ret) {
+		if (loop == MAC_LOOP_NONE)
+			h->dev->ops->set_promisc_mode(
+				h, ndev->flags & IFF_PROMISC);
+		else
+			h->dev->ops->set_promisc_mode(h, 1);
+	}
 	return ret;
 }
 
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH V2 for-next 6/8] net: hns: fix the bug of forwarding table
From: Salil Mehta @ 2016-09-29 17:09 UTC (permalink / raw)
  To: dledford
  Cc: salil.mehta, yisen.zhuang, xavier.huwei, oulijun, mehta.salil.lnk,
	linux-rdma, netdev, linux-kernel, linuxarm, Daode Huang
In-Reply-To: <20160929170916.631972-1-salil.mehta@huawei.com>

From: Daode Huang <huangdaode@hisilicon.com>

As the sub queue id in the broadcast forwarding table is always
set to absolute queue 0 rather than the interface's relative queue 0,
this will cause the received broadcast packets loopback to rcb.
This patch sets the sub queue id to relative queue 0 of each port.

Signed-off-by: Daode Huang <huangdaode@hisilicon.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
PATCH V2: Addressed comments by David Miller
          Link: https://lkml.org/lkml/2016/9/28/390
PATCH V1: Initial Submit
---
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c |    8 ++++++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c |   13 ++++++++++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h |    2 ++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index e0f9cdc..2d0cb60 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -207,6 +207,7 @@ static int hns_ae_set_multicast_one(struct hnae_handle *handle, void *addr)
 	int ret;
 	char *mac_addr = (char *)addr;
 	struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);
+	u8 port_num;
 
 	assert(mac_cb);
 
@@ -221,8 +222,11 @@ static int hns_ae_set_multicast_one(struct hnae_handle *handle, void *addr)
 		return ret;
 	}
 
-	ret = hns_mac_set_multi(mac_cb, DSAF_BASE_INNER_PORT_NUM,
-				mac_addr, true);
+	ret = hns_mac_get_inner_port_num(mac_cb, handle->vf_id, &port_num);
+	if (ret)
+		return ret;
+
+	ret = hns_mac_set_multi(mac_cb, port_num, mac_addr, true);
 	if (ret)
 		dev_err(handle->owner_dev,
 			"mac add mul_mac:%pM port%d  fail, ret = %#x!\n",
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index a68eef0..151fd6e 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -141,9 +141,10 @@ void hns_mac_adjust_link(struct hns_mac_cb *mac_cb, int speed, int duplex)
  *@port_num:port number
  *
  */
-static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
-				      u8 vmid, u8 *port_num)
+int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb, u8 vmid, u8 *port_num)
 {
+	int q_num_per_vf, vf_num_per_port;
+	int vm_queue_id;
 	u8 tmp_port;
 
 	if (mac_cb->dsaf_dev->dsaf_mode <= DSAF_MODE_ENABLE) {
@@ -174,6 +175,12 @@ static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
 		return -EINVAL;
 	}
 
+	q_num_per_vf = mac_cb->dsaf_dev->rcb_common[0]->max_q_per_vf;
+	vf_num_per_port = mac_cb->dsaf_dev->rcb_common[0]->max_vfn;
+
+	vm_queue_id = vmid * q_num_per_vf +
+			vf_num_per_port * q_num_per_vf * mac_cb->mac_id;
+
 	switch (mac_cb->dsaf_dev->dsaf_mode) {
 	case DSAF_MODE_ENABLE_FIX:
 		tmp_port = 0;
@@ -193,7 +200,7 @@ static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
 	case DSAF_MODE_DISABLE_6PORT_2VM:
 	case DSAF_MODE_DISABLE_6PORT_4VM:
 	case DSAF_MODE_DISABLE_6PORT_16VM:
-		tmp_port = vmid;
+		tmp_port = vm_queue_id;
 		break;
 	default:
 		dev_err(mac_cb->dev, "dsaf mode invalid,%s mac%d!\n",
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h
index 4cbdf14..d3a1f72 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h
@@ -461,5 +461,7 @@ void hns_set_led_opt(struct hns_mac_cb *mac_cb);
 int hns_cpld_led_set_id(struct hns_mac_cb *mac_cb,
 			enum hnae_led_state status);
 void hns_mac_set_promisc(struct hns_mac_cb *mac_cb, u8 en);
+int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,
+			       u8 vmid, u8 *port_num);
 
 #endif /* _HNS_DSAF_MAC_H */
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH V2 for-next 7/8] net: hns: bug fix about broadcast/multicast packets
From: Salil Mehta @ 2016-09-29 17:09 UTC (permalink / raw)
  To: dledford
  Cc: salil.mehta, yisen.zhuang, xavier.huwei, oulijun, mehta.salil.lnk,
	linux-rdma, netdev, linux-kernel, linuxarm, Daode Huang
In-Reply-To: <20160929170916.631972-1-salil.mehta@huawei.com>

From: Daode Huang <huangdaode@hisilicon.com>

When the dsaf mode receives a broadcast packet, it will filter
the packet by comparing the received queue number and destination
queue number(get from forwarding table), if they are the same,
the packet will be filtered. Otherwise, the packet will be loopback.
So this patch select queue 0 to send broadcast and multicast packets.

Signed-off-by: Daode Huang <huangdaode@hisilicon.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
PATCH v2: Addressed comments by David Miller
          Link: https://lkml.org/lkml/2016/9/28/390
PATCH V1: Initial Submit
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 09ed237..5494e0e 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1597,6 +1597,21 @@ struct rtnl_link_stats64 *hns_nic_get_stats64(struct net_device *ndev,
 	return stats;
 }
 
+static u16
+hns_nic_select_queue(struct net_device *ndev, struct sk_buff *skb,
+		     void *accel_priv, select_queue_fallback_t fallback)
+{
+	struct ethhdr *eth_hdr = (struct ethhdr *)skb->data;
+	struct hns_nic_priv *priv = netdev_priv(ndev);
+
+	/* fix hardware broadcast/multicast packets queue loopback */
+	if (!AE_IS_VER1(priv->enet_ver) &&
+	    is_multicast_ether_addr(eth_hdr->h_dest))
+		return 0;
+	else
+		return fallback(ndev, skb);
+}
+
 static const struct net_device_ops hns_nic_netdev_ops = {
 	.ndo_open = hns_nic_net_open,
 	.ndo_stop = hns_nic_net_stop,
@@ -1612,6 +1627,7 @@ static const struct net_device_ops hns_nic_netdev_ops = {
 	.ndo_poll_controller = hns_nic_poll_controller,
 #endif
 	.ndo_set_rx_mode = hns_nic_set_rx_mode,
+	.ndo_select_queue = hns_nic_select_queue,
 };
 
 static void hns_nic_update_link_status(struct net_device *netdev)
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH V2 for-next 8/8] net: hns: delete redundant broadcast packet filter process
From: Salil Mehta @ 2016-09-29 17:09 UTC (permalink / raw)
  To: dledford
  Cc: salil.mehta, yisen.zhuang, xavier.huwei, oulijun, mehta.salil.lnk,
	linux-rdma, netdev, linux-kernel, linuxarm, Daode Huang
In-Reply-To: <20160929170916.631972-1-salil.mehta@huawei.com>

From: Daode Huang <huangdaode@hisilicon.com>

The broadcast packets is filtered in the hardware now, so this process
is no need in the driver, just delete it.

Signed-off-by: Daode Huang <huangdaode@hisilicon.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c |   10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 5494e0e..a7abe11 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -574,7 +574,6 @@ static int hns_nic_poll_rx_skb(struct hns_nic_ring_data *ring_data,
 	struct sk_buff *skb;
 	struct hnae_desc *desc;
 	struct hnae_desc_cb *desc_cb;
-	struct ethhdr *eh;
 	unsigned char *va;
 	int bnum, length, i;
 	int pull_len;
@@ -600,7 +599,6 @@ static int hns_nic_poll_rx_skb(struct hns_nic_ring_data *ring_data,
 		ring->stats.sw_err_cnt++;
 		return -ENOMEM;
 	}
-	skb_reset_mac_header(skb);
 
 	prefetchw(skb->data);
 	length = le16_to_cpu(desc->rx.pkt_len);
@@ -682,14 +680,6 @@ out_bnum_err:
 		return -EFAULT;
 	}
 
-	/* filter out multicast pkt with the same src mac as this port */
-	eh = eth_hdr(skb);
-	if (unlikely(is_multicast_ether_addr(eh->h_dest) &&
-		     ether_addr_equal(ndev->dev_addr, eh->h_source))) {
-		dev_kfree_skb_any(skb);
-		return -EFAULT;
-	}
-
 	ring->stats.rx_pkts++;
 	ring->stats.rx_bytes += skb->len;
 
-- 
1.7.9.5

^ permalink raw reply related

* [rdma-core] Eliminate GCC warnings
From: Jason Gunthorpe @ 2016-09-29 17:09 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Leon Romanovsky

This patch series has already been applied, oops. I sent the pull
request, then got TravisCI working then ran out of time to send to the
list before Doug picked it.

Anyhow, most patches were on the list already in this group, save for
a few for ibacm.

Here are the commits, squashed diff below.

https://github.com/linux-rdma/rdma-core/compare/6f2c2b0021cc35e991808aeb825b7221f9e031b4...ad48f384594facfc73f9b9467c9a4bd33500ba02

If anyone has concerns..

The notable change is this makes TravisCI use -Werror, and runs the
build on 32 bit as well. So all future commits must be warning free on
64/32 bit GCC 6.2 to keep Travis happy.

Jason

 .travis.yml                         |   16 ++++++++-
 ibacm/src/acm.c                     |    9 ++---
 ibacm/src/acme.c                    |    5 +--
 iwpmd/src/iwarp_pm_helper.c         |    2 -
 libhfi1verbs/src/verbs.c            |    2 -
 libi40iw/src/i40iw_uverbs.c         |    6 +--
 libibumad/tests/umad_reg2_compat.c  |    1 
 libibverbs/examples/asyncwatch.c    |    2 -
 libibverbs/examples/pingpong.c      |    2 -
 libibverbs/examples/rc_pingpong.c   |   19 +++++------
 libibverbs/examples/srq_pingpong.c  |   17 +++++++---
 libibverbs/examples/uc_pingpong.c   |   19 +++++------
 libibverbs/examples/ud_pingpong.c   |   21 +++++--------
 libibverbs/examples/xsrq_pingpong.c |    4 +-
 libibverbs/src/neigh.c              |   21 ++++++-------
 libipathverbs/src/verbs.c           |    2 -
 libmlx5/src/verbs.c                 |    4 +-
 libnes/src/nes_uverbs.c             |   21 +++++++------
 libocrdma/src/ocrdma_verbs.c        |    3 +
 librdmacm/examples/cmtime.c         |   16 ---------
 librdmacm/src/acm.c                 |    3 +
 librdmacm/src/rsocket.c             |   58 +++++++++++++++++++++++++-----------
 librxe/src/rxe.c                    |    6 +++
 23 files changed, 146 insertions(+), 113 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index e09dd32ffa9f..a2b9e3b8c3f3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,8 +21,20 @@ addons:
       - pkg-config
       - python
       - valgrind
+
+      # 32 bit support packages
+      - gcc-multilib
+      - lib32gcc-6-dev
 script:
-  - mkdir build
+  - mkdir build build32
   - cd build
-  - CC=gcc-6 cmake -GNinja ..
+  # The goal is warning free compile on latest gcc.
+  - CC=gcc-6 CFLAGS=-Werror cmake -GNinja ..
+  - ninja
+
+  # 32 bit build
+  - cd ../build32
+  # travis's trusty is not configured in a way that enables all32 bit
+  # packages. We could fix this with some sudo stuff.. For now turn off libnl
+  - CC=gcc-6 CFLAGS="-Werror -m32" cmake -GNinja .. -DENABLE_RESOLVE_NEIGH=0
   - ninja
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 4650421b81b7..41429e1db4d7 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -218,7 +218,7 @@ static struct sa_data {
 	struct pollfd	*fds;
 	struct acmc_port **ports;
 	int		nfds;
-} sa = { 2000, 2, 1};
+} sa = { 2000, 2, 1, 0, NULL, NULL, 0};
 
 /*
  * Service options - may be set through ibacm_opts.cfg file.
@@ -1402,7 +1402,7 @@ static int acm_nl_send(SOCKET sock, struct acm_msg *msg)
 	int ret;
 	int datalen;
 
-	orig = (struct acm_nl_msg *) msg->hdr.tid;
+	orig = (struct acm_nl_msg *)(uintptr_t)msg->hdr.tid;
 
 	memset(&dst_addr, 0, sizeof(dst_addr));
 	dst_addr.nl_family = AF_NETLINK;
@@ -1562,7 +1562,7 @@ static void acm_nl_process_invalid_request(struct acmc_client *client,
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.length = ACM_MSG_HDR_LENGTH;
 	msg.hdr.status = ACM_STATUS_EINVAL;
-	msg.hdr.tid = (uint64_t) acmnlmsg;
+	msg.hdr.tid = (uintptr_t) acmnlmsg;
 
 	acm_nl_send(client->sock, &msg);
 }
@@ -1584,7 +1584,7 @@ static void acm_nl_process_resolve(struct acmc_client *client,
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.length = ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH;
 	msg.hdr.status = ACM_STATUS_SUCCESS;
-	msg.hdr.tid = (uint64_t) acmnlmsg;
+	msg.hdr.tid = (uintptr_t) acmnlmsg;
 	msg.resolve_data[0].type = ACM_EP_INFO_PATH;
 
 	/* We support only one pathrecord */
@@ -3031,7 +3031,6 @@ static int acm_open_lock_file(void)
 
 	snprintf(pid, sizeof pid, "%d\n", getpid());
 	if (write(lock_fd, pid, strlen(pid)) != strlen(pid)){
-		lockf(lock_fd, F_ULOCK, 0);
 		close(lock_fd);
 		return -1;
 	}
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index 4d9003047506..4b5fe684c8e2 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -38,6 +38,7 @@
 #include <getopt.h>
 #include <netdb.h>
 #include <arpa/inet.h>
+#include <inttypes.h>
 
 #include <osd.h>
 #include <infiniband/verbs.h>
@@ -902,7 +903,7 @@ static int enumerate_ep(char *svc, int index)
 		labels = 1;
 	}
 
-	printf("%s,0x%016lx,%d,0x%04x,%d,%s", svc, ep_data->dev_guid,
+	printf("%s,0x%016" PRIx64 ",%d,0x%04x,%d,%s", svc, ep_data->dev_guid,
 	       ep_data->port_num, ep_data->pkey, index, ep_data->prov_name);
 	for (i = 0; i < ep_data->addr_cnt; i++) 
 		printf(",%s", ep_data->addrs[i].name);
@@ -927,7 +928,7 @@ static void enumerate_eps(char *svc)
 static int query_svcs(void)
 {
 	char **svc_list;
-	int ret, i;
+	int ret = -1, i;
 
 	svc_list = parse(svc_arg, NULL);
 	if (!svc_list) {
diff --git a/iwpmd/src/iwarp_pm_helper.c b/iwpmd/src/iwarp_pm_helper.c
index f5c7b96a22e1..89d2b6cef5e6 100644
--- a/iwpmd/src/iwarp_pm_helper.c
+++ b/iwpmd/src/iwarp_pm_helper.c
@@ -82,7 +82,7 @@ iwpm_mapping_request *create_iwpm_map_request(struct nlmsghdr *req_nlh,
 	/* assochandle helps match iwpm request sent to remote peer with future iwpm accept/reject */
 	iwpm_map_req->assochandle = assochandle;
 	if (!assochandle)
-		iwpm_map_req->assochandle = (__u64)iwpm_map_req;
+		iwpm_map_req->assochandle = (uintptr_t)iwpm_map_req;
 
 	memcpy(&iwpm_map_req->src_addr, src_addr, sizeof(struct sockaddr_storage));
 	/* keep record of remote IP address and port */
diff --git a/libhfi1verbs/src/verbs.c b/libhfi1verbs/src/verbs.c
index 854c5676908d..e245ad9e5b4f 100644
--- a/libhfi1verbs/src/verbs.c
+++ b/libhfi1verbs/src/verbs.c
@@ -607,7 +607,7 @@ int hfi1_modify_srq(struct ibv_srq *ibsrq,
 			 (sizeof(struct ibv_sge) * srq->rq.max_sge)) *
 			srq->rq.size;
 	}
-	cmd.offset_addr = (__u64) &offset;
+	cmd.offset_addr = (uintptr_t) &offset;
 	ret = ibv_cmd_modify_srq(ibsrq, attr, attr_mask,
 				 &cmd.ibv_cmd, sizeof cmd);
 	if (ret) {
diff --git a/libi40iw/src/i40iw_uverbs.c b/libi40iw/src/i40iw_uverbs.c
index da23e4c9f413..8369e10f61ee 100644
--- a/libi40iw/src/i40iw_uverbs.c
+++ b/libi40iw/src/i40iw_uverbs.c
@@ -557,7 +557,7 @@ static int i40iw_vmapped_qp(struct i40iw_uqp *iwuqp, struct ibv_pd *pd,
 		return 0;
 	}
 	cmd.user_wqe_buffers = (__u64)((uintptr_t)info->sq);
-	cmd.user_compl_ctx = (u64)&iwuqp->qp;
+	cmd.user_compl_ctx = (uintptr_t)&iwuqp->qp;
 
 	ret = ibv_cmd_create_qp(pd, &iwuqp->ibv_qp, attr, &cmd.ibv_cmd, sizeof(cmd),
 				&resp->ibv_resp, sizeof(struct i40iw_ucreate_qp_resp));
@@ -858,7 +858,7 @@ int i40iw_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, struct ibv
 				info.op_type = I40IW_OP_TYPE_SEND;
 
 			if (ib_wr->send_flags & IBV_SEND_INLINE) {
-				info.op.inline_send.data = (void *)ib_wr->sg_list[0].addr;
+			  info.op.inline_send.data = (void *)(uintptr_t)ib_wr->sg_list[0].addr;
 				info.op.inline_send.len = ib_wr->sg_list[0].length;
 				ret = iwuqp->qp.ops.iw_inline_send(&iwuqp->qp, &info,
 								   ib_wr->wr.rdma.rkey, false);
@@ -881,7 +881,7 @@ int i40iw_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr, struct ibv
 			info.op_type = I40IW_OP_TYPE_RDMA_WRITE;
 
 			if (ib_wr->send_flags & IBV_SEND_INLINE) {
-				info.op.inline_rdma_write.data = (void *)ib_wr->sg_list[0].addr;
+			  info.op.inline_rdma_write.data = (void *)(uintptr_t)ib_wr->sg_list[0].addr;
 				info.op.inline_rdma_write.len = ib_wr->sg_list[0].length;
 				info.op.inline_rdma_write.rem_addr.tag_off = ib_wr->wr.rdma.remote_addr;
 				info.op.inline_rdma_write.rem_addr.len = ib_wr->sg_list->length;
diff --git a/libibumad/tests/umad_reg2_compat.c b/libibumad/tests/umad_reg2_compat.c
index 6dd4a48a59b2..9c239ee4bfae 100644
--- a/libibumad/tests/umad_reg2_compat.c
+++ b/libibumad/tests/umad_reg2_compat.c
@@ -100,7 +100,6 @@ int open_test_device(void)
 
 void test_register(void)
 {
-	int rc = 0;
 	int agent_id;
 	long method_mask[16 / sizeof(long)];
 	uint32_t class_oui = 0x001405; /* OPENIB_OUI */
diff --git a/libibverbs/examples/asyncwatch.c b/libibverbs/examples/asyncwatch.c
index df1261503b7d..c78994d24bed 100644
--- a/libibverbs/examples/asyncwatch.c
+++ b/libibverbs/examples/asyncwatch.c
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
 		static struct option long_options[] = {
 			{ .name = "ib-dev",    .has_arg = 1, .val = 'd' },
 			{ .name = "help",      .has_arg = 0, .val = 'h' },
-			{ 0 }
+			{}
 		};
 
 		c = getopt_long(argc, argv, "d:h", long_options, NULL);
diff --git a/libibverbs/examples/pingpong.c b/libibverbs/examples/pingpong.c
index 2fe4a04115fb..f6a50e9c62aa 100644
--- a/libibverbs/examples/pingpong.c
+++ b/libibverbs/examples/pingpong.c
@@ -44,7 +44,7 @@ enum ibv_mtu pp_mtu_to_enum(int mtu)
 	case 1024: return IBV_MTU_1024;
 	case 2048: return IBV_MTU_2048;
 	case 4096: return IBV_MTU_4096;
-	default:   return -1;
+	default:   return 0;
 	}
 }
 
diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c
index 967678362833..9054a68b7eb5 100644
--- a/libibverbs/examples/rc_pingpong.c
+++ b/libibverbs/examples/rc_pingpong.c
@@ -208,14 +208,13 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
 		goto out;
 	}
 
-	if (read(sockfd, msg, sizeof msg) != sizeof msg) {
-		perror("client read");
-		fprintf(stderr, "Couldn't read remote address\n");
+	if (read(sockfd, msg, sizeof msg) != sizeof msg ||
+	    write(sockfd, "done", sizeof "done") != sizeof "done") {
+		perror("client read/write");
+		fprintf(stderr, "Couldn't read/write remote address\n");
 		goto out;
 	}
 
-	write(sockfd, "done", sizeof "done");
-
 	rem_dest = malloc(sizeof *rem_dest);
 	if (!rem_dest)
 		goto out;
@@ -316,14 +315,14 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
 	gid_to_wire_gid(&my_dest->gid, gid);
 	sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
 							my_dest->psn, gid);
-	if (write(connfd, msg, sizeof msg) != sizeof msg) {
-		fprintf(stderr, "Couldn't send local address\n");
+	if (write(connfd, msg, sizeof msg) != sizeof msg ||
+	    read(connfd, msg, sizeof msg) != sizeof msg) {
+		fprintf(stderr, "Couldn't send/recv local address\n");
 		free(rem_dest);
 		rem_dest = NULL;
 		goto out;
 	}
 
-	read(connfd, msg, sizeof msg);
 
 out:
 	close(connfd);
@@ -732,7 +731,7 @@ int main(int argc, char *argv[])
 			{ .name = "gid-idx",  .has_arg = 1, .val = 'g' },
 			{ .name = "odp",      .has_arg = 0, .val = 'o' },
 			{ .name = "ts",       .has_arg = 0, .val = 't' },
-			{ 0 }
+			{}
 		};
 
 		c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:ot",
@@ -768,7 +767,7 @@ int main(int argc, char *argv[])
 
 		case 'm':
 			mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
-			if (mtu < 0) {
+			if (mtu == 0) {
 				usage(argv[0]);
 				return 1;
 			}
diff --git a/libibverbs/examples/srq_pingpong.c b/libibverbs/examples/srq_pingpong.c
index a1061c31972d..f17972580b57 100644
--- a/libibverbs/examples/srq_pingpong.c
+++ b/libibverbs/examples/srq_pingpong.c
@@ -222,8 +222,10 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
 		wire_gid_to_gid(gid, &rem_dest[i].gid);
 	}
 
-	write(sockfd, "done", sizeof "done");
-
+	if (write(sockfd, "done", sizeof "done") != sizeof "done") {
+		perror("client write");
+		goto out;
+	}
 out:
 	close(sockfd);
 	return rem_dest;
@@ -333,7 +335,12 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
 		}
 	}
 
-	read(connfd, msg, sizeof msg);
+	if (read(connfd, msg, sizeof msg) != sizeof msg) {
+		perror("client write");
+		free(rem_dest);
+		rem_dest = NULL;
+		goto out;
+	}
 
 out:
 	close(connfd);
@@ -658,7 +665,7 @@ int main(int argc, char *argv[])
 			{ .name = "sl",       .has_arg = 1, .val = 'l' },
 			{ .name = "events",   .has_arg = 0, .val = 'e' },
 			{ .name = "gid-idx",  .has_arg = 1, .val = 'g' },
-			{ 0 }
+			{}
 		};
 
 		c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:",
@@ -697,7 +704,7 @@ int main(int argc, char *argv[])
 
 		case 'm':
 			mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
-			if (mtu < 0) {
+			if (mtu == 0) {
 				usage(argv[0]);
 				return 1;
 			}
diff --git a/libibverbs/examples/uc_pingpong.c b/libibverbs/examples/uc_pingpong.c
index b25d16c79021..7d982d36a5ef 100644
--- a/libibverbs/examples/uc_pingpong.c
+++ b/libibverbs/examples/uc_pingpong.c
@@ -176,13 +176,13 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
 		goto out;
 	}
 
-	if (read(sockfd, msg, sizeof msg) != sizeof msg) {
-		perror("client read");
-		fprintf(stderr, "Couldn't read remote address\n");
+	if (read(sockfd, msg, sizeof msg) != sizeof msg ||
+	    write(sockfd, "done", sizeof "done") != sizeof "done") {
+		perror("client read/write");
+		fprintf(stderr, "Couldn't read/write remote address\n");
 		goto out;
 	}
 
-	write(sockfd, "done", sizeof "done");
 
 	rem_dest = malloc(sizeof *rem_dest);
 	if (!rem_dest)
@@ -284,15 +284,14 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
 	gid_to_wire_gid(&my_dest->gid, gid);
 	sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
 							my_dest->psn, gid);
-	if (write(connfd, msg, sizeof msg) != sizeof msg) {
-		fprintf(stderr, "Couldn't send local address\n");
+	if (write(connfd, msg, sizeof msg) != sizeof msg ||
+	    read(connfd, msg, sizeof msg) != sizeof msg) {
+		fprintf(stderr, "Couldn't send/recv local address\n");
 		free(rem_dest);
 		rem_dest = NULL;
 		goto out;
 	}
 
-	read(connfd, msg, sizeof msg);
-
 out:
 	close(connfd);
 	return rem_dest;
@@ -569,7 +568,7 @@ int main(int argc, char *argv[])
 			{ .name = "sl",       .has_arg = 1, .val = 'l' },
 			{ .name = "events",   .has_arg = 0, .val = 'e' },
 			{ .name = "gid-idx",  .has_arg = 1, .val = 'g' },
-			{ 0 }
+			{}
 		};
 
 		c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:",
@@ -604,7 +603,7 @@ int main(int argc, char *argv[])
 
 		case 'm':
 			mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
-			if (mtu < 0) {
+			if (mtu == 0) {
 				usage(argv[0]);
 				return 1;
 			}
diff --git a/libibverbs/examples/ud_pingpong.c b/libibverbs/examples/ud_pingpong.c
index fa99b9e51dfb..deefb9b81013 100644
--- a/libibverbs/examples/ud_pingpong.c
+++ b/libibverbs/examples/ud_pingpong.c
@@ -176,14 +176,13 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
 		goto out;
 	}
 
-	if (read(sockfd, msg, sizeof msg) != sizeof msg) {
-		perror("client read");
-		fprintf(stderr, "Couldn't read remote address\n");
+	if (read(sockfd, msg, sizeof msg) != sizeof msg ||
+	    write(sockfd, "done", sizeof "done") != sizeof "done") {
+		perror("client read/write");
+		fprintf(stderr, "Couldn't read/write remote address\n");
 		goto out;
 	}
 
-	write(sockfd, "done", sizeof "done");
-
 	rem_dest = malloc(sizeof *rem_dest);
 	if (!rem_dest)
 		goto out;
@@ -282,15 +281,13 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
 	gid_to_wire_gid(&my_dest->gid, gid);
 	sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
 							my_dest->psn, gid);
-	if (write(connfd, msg, sizeof msg) != sizeof msg) {
-		fprintf(stderr, "Couldn't send local address\n");
+	if (write(connfd, msg, sizeof msg) != sizeof msg ||
+	    read(connfd, msg, sizeof msg) != sizeof msg) {
+		fprintf(stderr, "Couldn't send/recv local address\n");
 		free(rem_dest);
 		rem_dest = NULL;
 		goto out;
 	}
-
-	read(connfd, msg, sizeof msg);
-
 out:
 	close(connfd);
 	return rem_dest;
@@ -327,7 +324,7 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
 	}
 
 	{
-		struct ibv_port_attr port_info = { 0 };
+		struct ibv_port_attr port_info = {};
 		int mtu;
 
 		if (ibv_query_port(ctx->context, port, &port_info)) {
@@ -591,7 +588,7 @@ int main(int argc, char *argv[])
 			{ .name = "sl",       .has_arg = 1, .val = 'l' },
 			{ .name = "events",   .has_arg = 0, .val = 'e' },
 			{ .name = "gid-idx",  .has_arg = 1, .val = 'g' },
-			{ 0 }
+			{}
 		};
 
 		c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:",
diff --git a/libibverbs/examples/xsrq_pingpong.c b/libibverbs/examples/xsrq_pingpong.c
index ff00180f2644..903548ed6824 100644
--- a/libibverbs/examples/xsrq_pingpong.c
+++ b/libibverbs/examples/xsrq_pingpong.c
@@ -875,7 +875,7 @@ int main(int argc, char *argv[])
 			{ .name = "sl",        .has_arg = 1, .val = 'l' },
 			{ .name = "events",    .has_arg = 0, .val = 'e' },
 			{ .name = "gid-idx",   .has_arg = 1, .val = 'g' },
-			{ 0 }
+			{}
 		};
 
 		c = getopt_long(argc, argv, "p:d:i:s:m:c:n:l:eg:", long_options,
@@ -906,7 +906,7 @@ int main(int argc, char *argv[])
 			break;
 		case 'm':
 			ctx.mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
-			if (ctx.mtu < 0) {
+			if (ctx.mtu == 0) {
 				usage(argv[0]);
 				return 1;
 			}
diff --git a/libibverbs/src/neigh.c b/libibverbs/src/neigh.c
index 799b810a9ec4..5acfcf06fcde 100644
--- a/libibverbs/src/neigh.c
+++ b/libibverbs/src/neigh.c
@@ -19,6 +19,7 @@
 #include <unistd.h>
 #include <ifaddrs.h>
 #include <netdb.h>
+#include <assert.h>
 #ifndef _LINUX_IF_H
 #include <net/if.h>
 #else
@@ -207,7 +208,7 @@ static int create_socket(struct get_neigh_handler *neigh_handler,
 				    &addr_src.len);
 	if (err) {
 		errno = EADDRNOTAVAIL;
-		return err;
+		return -1;
 	}
 
 	addr_dst->len = sizeof(addr_dst->sktaddr);
@@ -216,24 +217,22 @@ static int create_socket(struct get_neigh_handler *neigh_handler,
 				    &addr_dst->len);
 	if (err) {
 		errno = EADDRNOTAVAIL;
-		return err;
+		return -1;
 	}
 
 	err = set_link_port(&addr_dst->sktaddr, PORT_DISCARD,
 			    neigh_handler->oif);
 	if (err)
-		return err;
+		return -1;
 
 	sock_fd = socket(addr_dst->sktaddr.s.sa_family,
 			 SOCK_DGRAM | SOCK_CLOEXEC, 0);
 	if (sock_fd == -1)
-		return errno ? -errno : -1;
+		return -1;
 	err = bind(sock_fd, &addr_src.sktaddr.s, addr_src.len);
 	if (err) {
-		int bind_err = -errno;
-
 		close(sock_fd);
-		return bind_err ?: EADDRNOTAVAIL;
+		return -1;
 	}
 
 	*psock_fd = sock_fd;
@@ -374,9 +373,11 @@ static struct nl_addr *process_get_neigh_mac(
 
 			if (FD_ISSET(timer_fd, &fdset)) {
 				uint64_t read_val;
+				ssize_t rc;
 
-				(void)read(timer_fd, &read_val,
-					   sizeof(read_val));
+				rc =
+				    read(timer_fd, &read_val, sizeof(read_val));
+				assert(rc == sizeof(read_val));
 				if (++retries >=  NUM_OF_TRIES) {
 					if (!errno)
 						errno = EDESTADDRREQ;
@@ -729,7 +730,7 @@ uint16_t neigh_get_vlan_id_from_dev(struct get_neigh_handler *neigh_handler)
 
 void neigh_set_vlan_id(struct get_neigh_handler *neigh_handler, uint16_t vid)
 {
-	if (vid >= 0 && vid <= 0xfff)
+	if (vid <= 0xfff)
 		neigh_handler->vid = vid;
 }
 
diff --git a/libipathverbs/src/verbs.c b/libipathverbs/src/verbs.c
index 17d54cd4026b..578a38af3428 100644
--- a/libipathverbs/src/verbs.c
+++ b/libipathverbs/src/verbs.c
@@ -583,7 +583,7 @@ int ipath_modify_srq(struct ibv_srq *ibsrq,
 			 (sizeof(struct ibv_sge) * srq->rq.max_sge)) *
 			srq->rq.size;
 	}
-	cmd.offset_addr = (__u64) &offset;
+	cmd.offset_addr = (uintptr_t) &offset;
 	ret = ibv_cmd_modify_srq(ibsrq, attr, attr_mask,
 				 &cmd.ibv_cmd, sizeof cmd);
 	if (ret) {
diff --git a/libmlx5/src/verbs.c b/libmlx5/src/verbs.c
index 52289acc39cc..75cbae35e759 100644
--- a/libmlx5/src/verbs.c
+++ b/libmlx5/src/verbs.c
@@ -1700,8 +1700,8 @@ mlx5_open_xrcd(struct ibv_context *context,
 {
 	int err;
 	struct verbs_xrcd *xrcd;
-	struct ibv_open_xrcd cmd = {0};
-	struct ibv_open_xrcd_resp resp = {0};
+	struct ibv_open_xrcd cmd = {};
+	struct ibv_open_xrcd_resp resp = {};
 
 	xrcd = calloc(1, sizeof(*xrcd));
 	if (!xrcd)
diff --git a/libnes/src/nes_uverbs.c b/libnes/src/nes_uverbs.c
index 80891d6243c7..983d87a80b8b 100644
--- a/libnes/src/nes_uverbs.c
+++ b/libnes/src/nes_uverbs.c
@@ -215,6 +215,7 @@ int nes_udereg_mr(struct ibv_mr *mr)
 	return 0;
 }
 
+#if HAVE_DECL_IBV_QPT_RAW_ETH
 static
 int nes_ima_ureplace_cq(struct ibv_cq *cq,
 			int mcrqf,
@@ -296,6 +297,7 @@ int nes_ima_ureplace_cq(struct ibv_cq *cq,
  err:
 	return ret;
 }
+#endif
 
 /**
  * nes_ucreate_cq
@@ -425,7 +427,6 @@ int nes_ima_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry)
 	int cqe_count = 0;
 	uint32_t head;
 	uint32_t cq_size;
-	uint16_t qp_size;
 
 	volatile struct nes_hw_nic_cqe *cqe = 0;
 	volatile struct nes_hw_nic_cqe *cqes;
@@ -487,7 +488,6 @@ int nes_ima_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry)
 			entry->src_qp = nesuqp->qp_id;
 			if (cqe_misc & NES_NIC_CQE_SQ) {
 				entry->opcode = IBV_WC_SEND;
-				qp_size = nesuqp->sq_size;
 
 				entry->wr_id =
 					nesuqp->send_wr_id[nesuqp->sq_tail];
@@ -518,8 +518,8 @@ int nes_ima_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry)
 				/* Working on a RQ Completion*/
 				if (++nesuqp->rq_tail >= nesuqp->rq_size)
 					nesuqp->rq_tail = 0;
-					if (entry->status == NES_CQ_BUF_OV_ERR)
-						entry->status = IBV_WC_LOC_LEN_ERR;
+				if (entry->status == NES_CQ_BUF_OV_ERR)
+					entry->status = IBV_WC_LOC_LEN_ERR;
 			}
 
 			if (++head >= cq_size)
@@ -557,7 +557,6 @@ int nes_upoll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *entry)
 	uint32_t wqe_index;
 	uint32_t wq_tail = 0;
 	struct nes_hw_cqe cqe;
-	uint32_t tmp;
 	uint64_t u64temp;
 	int move_cq_head = 1;
 	uint32_t err_code;
@@ -679,7 +678,6 @@ nes_upoll_cq_update:
 					nesvctx = to_nes_uctx(cq->context);
 				nesvctx->nesupd->udoorbell->cqe_alloc = cpu_to_le32(nesucq->cq_id |
 						(nesucq->polled_completions << 16));
-				tmp = nesvctx->nesupd->udoorbell->cqe_alloc;
 				nesucq->polled_completions = 0;
 			}
 		} else {
@@ -699,7 +697,6 @@ nes_upoll_cq_update:
 			nesvctx = to_nes_uctx(cq->context);
 		nesvctx->nesupd->udoorbell->cqe_alloc = cpu_to_le32(nesucq->cq_id |
 				(nesucq->polled_completions << 16));
-		tmp = nesvctx->nesupd->udoorbell->cqe_alloc;
 		nesucq->polled_completions = 0;
 	}
 	nesucq->head = head;
@@ -1140,7 +1137,6 @@ struct ibv_qp *nes_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
 	struct nes_uqp *nesuqp;
 	int	sqdepth, rqdepth;
 	int	 status = 1;
-	int i = 0;
 
 	/* fprintf(stderr, PFX "%s\n", __FUNCTION__); */
 
@@ -1211,6 +1207,8 @@ struct ibv_qp *nes_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
 
 #if HAVE_DECL_IBV_QPT_RAW_ETH
 	if (attr->qp_type == IBV_QPT_RAW_ETH) {
+		int i = 0;
+
 		nesuqp->nes_ud_sksq_fd = open("/dev/infiniband/nes_ud_sksq",
 						O_RDWR);
 		if (nesuqp->nes_ud_sksq_fd <= 0)
@@ -1327,7 +1325,6 @@ int nes_udestroy_qp(struct ibv_qp *qp)
 {
 	struct nes_uqp *nesuqp = to_nes_uqp(qp);
 	int ret = 0;
-	int i = 0;
 
 	// fprintf(stderr, PFX "%s addr&mr= %p  \n", __FUNCTION__, &nesuqp->mr );
 
@@ -1353,6 +1350,8 @@ int nes_udestroy_qp(struct ibv_qp *qp)
 
 #if HAVE_DECL_IBV_QPT_RAW_ETH
 	if (qp->qp_type == IBV_QPT_RAW_ETH) {
+		int i = 0;
+
 		if (nesuqp->pend_rx_wr) {
 			for (i = 0; i < NES_UD_RX_BATCH_SZ; i++)
 				if (nesuqp->pend_rx_wr[i].sg_list) {
@@ -1381,6 +1380,7 @@ int nes_udestroy_qp(struct ibv_qp *qp)
 	return 0;
 }
 
+#if HAVE_DECL_IBV_QPT_RAW_ETH
 static inline
 int nes_ima_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr,
 		struct ibv_send_wr **bad_wr)
@@ -1457,6 +1457,7 @@ int nes_ima_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr,
 out:
 	return ret;
 }
+#endif
 
 /**
  * nes_upost_send
@@ -1653,6 +1654,7 @@ int nes_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr,
 	return err;
 }
 
+#if HAVE_DECL_IBV_QPT_RAW_ETH
 static inline
 int nes_ima_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr,
 		struct ibv_recv_wr **bad_wr)
@@ -1727,6 +1729,7 @@ int nes_ima_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr,
 out:
 	return ret;
 }
+#endif
 
 /**
  * nes_upost_recv
diff --git a/libocrdma/src/ocrdma_verbs.c b/libocrdma/src/ocrdma_verbs.c
index 60626260656d..8eb70db2693a 100644
--- a/libocrdma/src/ocrdma_verbs.c
+++ b/libocrdma/src/ocrdma_verbs.c
@@ -945,10 +945,11 @@ static inline void *ocrdma_hwq_head(struct ocrdma_qp_hwq_info *q)
 	return q->va + (q->head * q->entry_size);
 }
 
-static inline void *ocrdma_wq_tail(struct ocrdma_qp_hwq_info *q)
+/*static inline void *ocrdma_wq_tail(struct ocrdma_qp_hwq_info *q)
 {
 	return q->va + (q->tail * q->entry_size);
 }
+*/
 
 static inline void *ocrdma_hwq_head_from_idx(struct ocrdma_qp_hwq_info *q,
 					     uint32_t idx)
diff --git a/librdmacm/examples/cmtime.c b/librdmacm/examples/cmtime.c
index e45980b9bb04..f0b4d0276288 100644
--- a/librdmacm/examples/cmtime.c
+++ b/librdmacm/examples/cmtime.c
@@ -128,13 +128,6 @@ static inline int __list_empty(struct work_list *list)
 	return list->list.next == &list->list;
 }
 
-static inline int list_empty(struct work_list *work_list)
-{
-	pthread_mutex_lock(&work_list->lock);
-	return work_list->list.next == &work_list->list;
-	pthread_mutex_unlock(&work_list->lock);
-}
-
 static inline struct list_head *__list_remove_head(struct work_list *work_list)
 {
 	struct list_head *list_item;
@@ -144,15 +137,6 @@ static inline struct list_head *__list_remove_head(struct work_list *work_list)
 	return list_item;
 }
 
-static inline struct list_head *list_remove_head(struct work_list *work_list)
-{
-	struct list_head *list_item;
-	pthread_mutex_lock(&work_list->lock);
-	list_item = __list_remove_head(work_list);
-	pthread_mutex_unlock(&work_list->lock);
-	return list_item;
-}
-
 static inline void list_add_tail(struct work_list *work_list, struct list_head *req)
 {
 	int empty;
diff --git a/librdmacm/src/acm.c b/librdmacm/src/acm.c
index 75d9d8cf487e..823381aac367 100644
--- a/librdmacm/src/acm.c
+++ b/librdmacm/src/acm.c
@@ -121,7 +121,8 @@ static int ucma_set_server_port(void)
 	FILE *f;
 
 	if ((f = fopen(IBACM_PORT_FILE, "r" STREAM_CLOEXEC))) {
-		fscanf(f, "%" SCNu16, &server_port);
+		if (fscanf(f, "%" SCNu16, &server_port) != 1)
+			server_port = 0;
 		fclose(f);
 	}
 	return server_port;
diff --git a/librdmacm/src/rsocket.c b/librdmacm/src/rsocket.c
index 818505fbe02e..205101f1702f 100644
--- a/librdmacm/src/rsocket.c
+++ b/librdmacm/src/rsocket.c
@@ -404,6 +404,20 @@ struct ds_udp_header {
 
 #define ds_next_qp(qp) container_of((qp)->list.next, struct ds_qp, list)
 
+static void write_all(int fd, const void *msg, size_t len)
+{
+	// FIXME: if fd is a socket this really needs to handle EINTR and other conditions.
+	ssize_t rc = write(fd, msg, len);
+	assert(rc == len);
+}
+
+static void read_all(int fd, void *msg, size_t len)
+{
+	// FIXME: if fd is a socket this really needs to handle EINTR and other conditions.
+	ssize_t rc = read(fd, msg, len);
+	assert(rc == len);
+}
+
 static void ds_insert_qp(struct rsocket *rs, struct ds_qp *qp)
 {
 	if (!rs->qp_list)
@@ -444,8 +458,8 @@ static int rs_notify_svc(struct rs_svc *svc, struct rsocket *rs, int cmd)
 	msg.cmd = cmd;
 	msg.status = EINVAL;
 	msg.rs = rs;
-	write(svc->sock[0], &msg, sizeof msg);
-	read(svc->sock[0], &msg, sizeof msg);
+	write_all(svc->sock[0], &msg, sizeof msg);
+	read_all(svc->sock[0], &msg, sizeof msg);
 	ret = rdma_seterrno(msg.status);
 	if (svc->cnt)
 		goto unlock;
@@ -484,6 +498,15 @@ static int rs_scale_to_value(int value, int bits)
 	       value : (value & ~(1 << (bits - 1))) << bits;
 }
 
+/* gcc > ~5 will not allow (void)fscanf to suppress -Wunused-result, but this
+   will do it.  In this case ignoring the result is OK (but horribly
+   unfriendly to user) since the library has a sane default. */
+#define failable_fscanf(f, fmt, ...)                                           \
+	{                                                                      \
+		int rc = fscanf(f, fmt, __VA_ARGS__);                          \
+		(void) rc;                                                     \
+	}
+
 void rs_configure(void)
 {
 	FILE *f;
@@ -501,27 +524,27 @@ void rs_configure(void)
 	ucma_ib_init();
 
 	if ((f = fopen(RS_CONF_DIR "/polling_time", "r"))) {
-		(void) fscanf(f, "%u", &polling_time);
+		failable_fscanf(f, "%u", &polling_time);
 		fclose(f);
 	}
 
 	if ((f = fopen(RS_CONF_DIR "/inline_default", "r"))) {
-		(void) fscanf(f, "%hu", &def_inline);
+		failable_fscanf(f, "%hu", &def_inline);
 		fclose(f);
 	}
 
 	if ((f = fopen(RS_CONF_DIR "/sqsize_default", "r"))) {
-		(void) fscanf(f, "%hu", &def_sqsize);
+		failable_fscanf(f, "%hu", &def_sqsize);
 		fclose(f);
 	}
 
 	if ((f = fopen(RS_CONF_DIR "/rqsize_default", "r"))) {
-		(void) fscanf(f, "%hu", &def_rqsize);
+		failable_fscanf(f, "%hu", &def_rqsize);
 		fclose(f);
 	}
 
 	if ((f = fopen(RS_CONF_DIR "/mem_default", "r"))) {
-		(void) fscanf(f, "%u", &def_mem);
+		failable_fscanf(f, "%u", &def_mem);
 		fclose(f);
 
 		if (def_mem < 1)
@@ -529,14 +552,14 @@ void rs_configure(void)
 	}
 
 	if ((f = fopen(RS_CONF_DIR "/wmem_default", "r"))) {
-		(void) fscanf(f, "%u", &def_wmem);
+		failable_fscanf(f, "%u", &def_wmem);
 		fclose(f);
 		if (def_wmem < RS_SNDLOWAT)
 			def_wmem = RS_SNDLOWAT << 1;
 	}
 
 	if ((f = fopen(RS_CONF_DIR "/iomap_size", "r"))) {
-		(void) fscanf(f, "%hu", &def_iomap_size);
+		failable_fscanf(f, "%hu", &def_iomap_size);
 		fclose(f);
 
 		/* round to supported values */
@@ -3345,7 +3368,8 @@ static int rs_set_keepalive(struct rsocket *rs, int on)
 	if (on) {
 		if (!rs->keepalive_time) {
 			if ((f = fopen("/proc/sys/net/ipv4/tcp_keepalive_time", "r"))) {
-				(void) fscanf(f, "%u", &rs->keepalive_time);
+				if (fscanf(f, "%u", &rs->keepalive_time) != 1)
+					rs->keepalive_time = 7200;
 				fclose(f);
 			} else {
 				rs->keepalive_time = 7200;
@@ -3985,7 +4009,7 @@ static void udp_svc_process_sock(struct rs_svc *svc)
 {
 	struct rs_svc_msg msg;
 
-	read(svc->sock[1], &msg, sizeof msg);
+	read_all(svc->sock[1], &msg, sizeof msg);
 	switch (msg.cmd) {
 	case RS_SVC_ADD_DGRAM:
 		msg.status = rs_svc_add_rs(svc, msg.rs);
@@ -4009,7 +4033,7 @@ static void udp_svc_process_sock(struct rs_svc *svc)
 		break;
 	}
 
-	write(svc->sock[1], &msg, sizeof msg);
+	write_all(svc->sock[1], &msg, sizeof msg);
 }
 
 static uint8_t udp_svc_sgid_index(struct ds_dest *dest, union ibv_gid *sgid)
@@ -4184,7 +4208,7 @@ static void *udp_svc_run(void *arg)
 	ret = rs_svc_grow_sets(svc, 4);
 	if (ret) {
 		msg.status = ret;
-		write(svc->sock[1], &msg, sizeof msg);
+		write_all(svc->sock[1], &msg, sizeof msg);
 		return (void *) (uintptr_t) ret;
 	}
 
@@ -4222,7 +4246,7 @@ static void tcp_svc_process_sock(struct rs_svc *svc)
 	struct rs_svc_msg msg;
 	int i;
 
-	read(svc->sock[1], &msg, sizeof msg);
+	read_all(svc->sock[1], &msg, sizeof msg);
 	switch (msg.cmd) {
 	case RS_SVC_ADD_KEEPALIVE:
 		msg.status = rs_svc_add_rs(svc, msg.rs);
@@ -4253,7 +4277,7 @@ static void tcp_svc_process_sock(struct rs_svc *svc)
 	default:
 		break;
 	}
-	write(svc->sock[1], &msg, sizeof msg);
+	write_all(svc->sock[1], &msg, sizeof msg);
 }
 
 /*
@@ -4266,7 +4290,7 @@ static void tcp_svc_send_keepalive(struct rsocket *rs)
 	if (rs_ctrl_avail(rs) && (rs->state & rs_connected)) {
 		rs->ctrl_seqno++;
 		rs_post_write(rs, NULL, 0, rs_msg_set(RS_OP_CTRL, RS_CTRL_KEEPALIVE),
-			      0, (uint64_t) NULL, (uint64_t) NULL);
+			      0, (uintptr_t) NULL, (uintptr_t) NULL);
 	}
 	fastlock_release(&rs->cq_lock);
 }	
@@ -4282,7 +4306,7 @@ static void *tcp_svc_run(void *arg)
 	ret = rs_svc_grow_sets(svc, 16);
 	if (ret) {
 		msg.status = ret;
-		write(svc->sock[1], &msg, sizeof msg);
+		write_all(svc->sock[1], &msg, sizeof msg);
 		return (void *) (uintptr_t) ret;
 	}
 
diff --git a/librxe/src/rxe.c b/librxe/src/rxe.c
index 94d0de51f7dd..7164f6627171 100644
--- a/librxe/src/rxe.c
+++ b/librxe/src/rxe.c
@@ -596,6 +596,12 @@ void convert_send_wr(struct rxe_send_wr *kwr, struct ibv_send_wr *uwr)
 		kwr->wr.atomic.swap		= uwr->wr.atomic.swap;
 		kwr->wr.atomic.rkey		= uwr->wr.atomic.rkey;
 		break;
+
+	case IBV_WR_LOCAL_INV:
+	case IBV_WR_BIND_MW:
+	case IBV_WR_SEND_WITH_INV:
+	case IBV_WR_TSO:
+		break;
 	}
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* RE: [PATCH for-next 0/8] Bug Fixes and Code Improvement in HNS driver
From: Salil Mehta @ 2016-09-29 17:16 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Huwei (Xavier), oulijun, Zhuangyuzeng (Yisen),
	mehta.salil.lnk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linuxarm
In-Reply-To: <57EBDA43.3010708-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

> Hi Salil,
> 
> I've chatted with Dave Miller about this series.  Here's where we
> stand.
> 
> First, the review feedback from Dave:
> 
> ---
> 
> In patch #7, their comments are mis-formatted and these
> hns guys do this a lot.
> 
> 	/*fix hardware broadcast/multicast packets queue loopback */
> 
> They seem to have a hard time putting an initial space in the comment,
> and properly capitalizing and punctuating their sentences.
> 
> Also in that new function, they need to order local variables from
> longest to shortest line (reverse christmas tree format).
> 
> Patch #6 has the local variable ordering issue as well as does patch
> #3.

Hi Doug,
I have refloated PATCH V2 with reworked 6/8 and 7/8 patches.

I scanned [PATCH V1 3/8] but could not find any ordering issue amongst
local variables there. I hope I have not missed anything.

Best regards
Salil
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 05/13] Have cmake run man pages through text substitution
From: ira.weiny @ 2016-09-29 18:37 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Hefty, Sean, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <20160926182154.GA27094-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

On Mon, Sep 26, 2016 at 12:21:54PM -0600, Jason Gunthorpe wrote:
> On Mon, Sep 26, 2016 at 06:17:03PM +0000, Weiny, Ira wrote:
> 
> > > rst2man is incredibly widely distributed: it comes with python-docutils which
> > > is widely included in every distribution. I have no idea why people would
> > > complain to you on that point. If something comes in-box in all the distros
> > > then it is fair game to depend upon, IMHO.
> > 
> > I thought so to.  But python-docutils is in the "optional" section of RH.
> 
> I mean it is available via 'yum' with no special repositories. I do
> not expect software to build out of the box on any arbitary distro
> install. I expect builders to install the required set of
> packages. This is why the exect package set is documented in the
> README.md

FWIW, I'm supportive of that.  Just saying what my experience was.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* PROBLEM: nvmet rxe : Kernel oops when running nvmf IO over rdma_rxe
From: Stephen Bates @ 2016-09-29 20:10 UTC (permalink / raw)
  To: linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, hch-jcswGhMUV9g,
	sagi-NQWnxTmZq1alnMjI0IkVqw, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	monis-VPRAkNaXOzVWk0Htik3J/w, yonatanc-VPRAkNaXOzVWk0Htik3J/w
  Cc: Stephen Bates

Hi All

So I thought I would try and run NVMe over Fabrics over
Soft-RoCE. Both were adding to 4.8 so what could possibly go wrong
;-). I am getting a pretty consistent kernel oops so I though I would
post this so people could take a look.

Cheers

Stephen

Problem
-------

Kernel panics when attempting to run NVMe over Fabrics I/O over
soft-RoCE.

Interestingly nvme discover and connect seem to go well. In some cases
I even seem to be able to issue some IO against the /dev/nvme0n1
device on the host. However pretty quick I get a kernel oops on the
target as shown below.

My testing of soft-roce itself using userspace tools like ib_write_bw
seem to be passing. So I am thinking the interaction between the
kernel space interface for RXE and NVMf are not playing well
together.

Suspect Modules
---------------

nvmet, rdma_rxe

Steps to Reproduce
------------------

1. Monolithic 4.8-rc8 kernel. I can provide a .config if people want
it.
2. Boot up two QEMU instances connected together via a e1000 vNIC and
a QEMU socket connection.
3. Bind rdma_rxe to the relevant ethernet ports on each VM using the
rxe_cfg user-space tool.
4. Setup NVMf target namespace on the target. I did this was a short
shell script.
5. Do nvme discover and connect on host (I used nvme-cli for this).
6. Try and issue IO on the NVMe block device created on the host.

Some of this is recorded in my qemu-minimal Github repo which you can
find here:

https://github.com/sbates130272/qemu-minimal

Oops Trace
-----------

I am including a couple of lines before the oops because I suspect
they might be relevant. addr2line decodes the last addrss in the call
trace as

ida_simple_remove(&nvmet_rdma_queue_ida, queue->idx);

[  272.511262] nvmet: creating controller 1 for NQN
nqn.2014-08.org.nvmexpress:NVMf:uuid:1fa5a811-6324-42bb-aab0-3e1fa4d14b90.
[  272.758552] nvmet: adding queue 1 to ctrl 1.
[  313.308896] nvmet_rdma: freeing queue 1
[  313.310315] nvmet_rdma: freeing queue 0
[  313.313056] general protection fault: 0000 [#1] SMP
[  313.313672] Modules linked in:
[  313.314015] CPU: 0 PID: 420 Comm: kworker/0:1 Not tainted 4.8.0-rc8
#50
[  313.314015] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org
04/01/2014
[  313.314015] Workqueue: events nvmet_rdma_release_queue_work
[  313.314015] task: ffff88007c728000 task.stack: ffff88007c750000
[  313.314015] RIP: 0010:[<ffffffff81453500>]  [<ffffffff81453500>]
nvmet_rdma_free_rsps+0x80/0x110
[  313.314015] RSP: 0018:ffff88007c753db8  EFLAGS: 00010282
[  313.314015] RAX: dead000000000200 RBX: ffff8800795c1320 RCX:
00000001810000e9
[  313.314015] RDX: dead000000000100 RSI: ffffea0001f07f80 RDI:
0000000040000000
[  313.314015] RBP: ffff88007c753de0 R08: 000000007c1feb01 R09:
00000001810000e9
[  313.314015] R10: ffffea0001f07f00 R11: ffffea0001f25800 R12:
0000000000001320
[  313.314015] R13: 0000000000008800 R14: ffff88007c2c6a00 R15:
ffff88007b93e400
[  313.314015] FS:  0000000000000000(0000) GS:ffff88007fc00000(0000)
knlGS:0000000000000000
[  313.314015] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  313.314015] CR2: 00007f13ddc13005 CR3: 000000007c1d4000 CR4:
00000000000006f0
[  313.314015] Stack:
[  313.314015]  ffff88007c2c6a00 0000000000000002 ffff88007c1adc00
ffff88007fc1b500
[  313.314015]  ffff88007c2c6ac8 ffff88007c753df8 ffffffff814537b9
ffff88007b93e400
[  313.314015]  ffff88007c753e20 ffffffff81453820 ffff88007d3bfd80
ffff88007fc17040
[  313.314015] Call Trace:
[  313.314015]  [<ffffffff814537b9>] nvmet_rdma_free_queue+0x49/0x90
[  313.314015]  [<ffffffff81453820>]
nvmet_rdma_release_queue_work+0x20/0x50
[  313.314015]  [<ffffffff8106d856>] process_one_work+0x146/0x410
[  313.314015]  [<ffffffff8106deb1>] worker_thread+0x61/0x490
[  313.314015]  [<ffffffff8106de50>] ? rescuer_thread+0x330/0x330
[  313.314015]  [<ffffffff8106de50>] ? rescuer_thread+0x330/0x330
[  313.314015]  [<ffffffff81072c06>] kthread+0xd6/0xf0
[  313.314015]  [<ffffffff8173ae8f>] ret_from_fork+0x1f/0x40
[  313.314015]  [<ffffffff81072b30>] ? kthread_park+0x50/0x50
[  313.314015] Code: c4 20 02 00 00 e8 b1 b2 d1 ff 4d 39 ec 0f 84 82
00 00 00 4c 89 e3 49 03 9e a0 00 00 00 48 8b 83 18 02 00 00 48 8b 93
10 02 00 00 <48> 89 42 08 48 89 10 48 b8 00 01 00 00 00 00 ad de 48 89
83 10
[  313.314015] RIP  [<ffffffff81453500>]
nvmet_rdma_free_rsps+0x80/0x110
[  313.314015]  RSP <ffff88007c753db8>

ver_linux
---------

Linux cgy1-donard 4.6.0+3-00004-ga573b70 #118 SMP Fri Jun 3 15:21:30
MDT 2016 x86_64 GNU/Linux

GNU C                   4.9.2
GNU Make                4.0
Binutils                2.25
Util-linux              2.25.2
Mount                   2.25.2
Linux C Library         2.19
Dynamic linker (ldd)    2.19
Procps                  3.3.9
Kbd                     1.15.5
Console-tools           1.15.5
Sh-utils                8.23
Udev                    215
Modules Loaded          ablk_helper acpi_cpufreq aesni_intel
aes_x86_64 ahci ansi_cprng auth_rpcgss autofs4 binfmt_misc bridge
br_netfilter btrfs button configfs coretemp crc32c_intel cryptd cxgb4
dca dm_mod drbg edac_core ehci_hcd ehci_pci evdev ext4 fscache fuse
gf128mul ghash_clmulni_intel glue_helper grace hid hid_generic hmac
i2c_algo_bit i2c_core i2c_i801 ib_addr ib_cm ib_core ib_ipoib ib_mad
ib_sa ib_umad ib_uverbs igb ioatdma ipmi_devintf ipmi_msghandler
ipmi_poweroff ipmi_si ipmi_watchdog iptable_filter iptable_nat
ip_tables ipt_MASQUERADE irqbypass isci iTCO_vendor_support iTCO_wdt
iw_cm iw_cxgb4 jbd2 joydev kvm kvm_intel libahci libata libnvdimm
libsas llc lockd loop lpc_ich lrw mbcache md_mod mfd_core mlx4_core
mlx4_ib mlx5_core mlx5_ib msr nd_btt nd_e820 nd_pmem nf_conntrack
nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat nf_nat_ipv4
nf_nat_masquerade_ipv4 nfs nfs_acl nfsd nvme nvme_core ohci_hcd
oid_registry overlay pcspkr pps_core processor psmouse ptp raid6_pq
rdma_cm rdma_ucm sb_edac scsi_mod scsi_transport_sas sd_mod serio_raw
sg sha256_generic shpchp stp sunrpc tpm tpm_tis tun uhci_hcd
usb_common usbcore usbhid wmi x86_pkg_temp_thermal xhci_hcd xor
x_tables xt_addrtype xt_conntrack


Cheers

Stephen
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH rdma-core 0/9] Dead Code Removal
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

This removes various #ifdef type stuff that no longer makes any sense.
cmake is arranged in a way that avoids alot of the ifdefs around header files.

The BYTE_ORDER patch is more substantial and consolidates everything around
glibc's endian.h

See

https://github.com/linux-rdma/rdma-core/pull/10

Jason Gunthorpe (9):
  Remove HAVE_CONFIG_H
  Remove HAVE_VALGRIND_MEMCHECK_H/INCLUDE_VALGRIND
  Remove HAVE_IBV_*
  Do not use IBV_CMD_(REG_MR|RESIZE_CQ)_HAS_RESP_PARAMS
  Remove HAVE_SYMVER_SUPPORT
  Remove old compat definitions of wmb/rmb/etc
  Remove old MADV_DONTFORK/DOFORK compat
  Remove most checks of __BYTE_ORDER
  nes: Remove code guarded by HAVE_DECL_IBV_QPT_RAW_ETH

 CMakeLists.txt                       |   2 -
 buildlib/config.h.in                 |  13 --
 ibacm/linux/osd.h                    |   8 +-
 ibacm/prov/acmp/src/acmp.c           |   4 +-
 ibacm/src/acm.c                      |   4 +-
 ibacm/src/acme.c                     |   4 +-
 ibacm/src/libacm.c                   |   4 +-
 libcxgb3/src/cq.c                    |   4 +-
 libcxgb3/src/cxio_wr.h               |  10 +-
 libcxgb3/src/iwch.c                  |   4 +-
 libcxgb3/src/qp.c                    |   4 +-
 libcxgb3/src/verbs.c                 |   4 +-
 libcxgb4/src/cq.c                    |   4 +-
 libcxgb4/src/dev.c                   |   4 +-
 libcxgb4/src/qp.c                    |   4 +-
 libcxgb4/src/t4.h                    |  11 +-
 libcxgb4/src/verbs.c                 |   4 +-
 libhfi1verbs/src/hfiverbs.c          |  22 +--
 libhfi1verbs/src/verbs.c             |  19 +-
 libi40iw/src/i40iw_umain.c           |   2 -
 libi40iw/src/i40iw_umain.h           |  18 +-
 libi40iw/src/i40iw_uverbs.c          |  28 ---
 libibcm/src/cm.c                     |  15 +-
 libibumad/src/sysfs.c                |  12 +-
 libibumad/src/umad.c                 |  18 +-
 libibumad/tests/umad_reg2_compat.c   |   4 +-
 libibumad/tests/umad_register2.c     |   4 +-
 libibverbs/examples/asyncwatch.c     |   4 +-
 libibverbs/examples/device_list.c    |   4 +-
 libibverbs/examples/devinfo.c        |   4 +-
 libibverbs/examples/rc_pingpong.c    |   4 +-
 libibverbs/examples/srq_pingpong.c   |   4 +-
 libibverbs/examples/uc_pingpong.c    |   4 +-
 libibverbs/examples/ud_pingpong.c    |   4 +-
 libibverbs/examples/xsrq_pingpong.c  |   4 +-
 libibverbs/include/infiniband/arch.h |  15 +-
 libibverbs/src/cmd.c                 |   4 +-
 libibverbs/src/compat-1_0.c          |   4 +-
 libibverbs/src/device.c              |   4 +-
 libibverbs/src/ibverbs.h             |  25 +--
 libibverbs/src/init.c                |   4 +-
 libibverbs/src/marshall.c            |   4 +-
 libibverbs/src/memory.c              |  15 +-
 libibverbs/src/sysfs.c               |   4 +-
 libibverbs/src/verbs.c               |   4 +-
 libipathverbs/src/ipathverbs.c       |  22 +--
 libipathverbs/src/verbs.c            |  20 +-
 libmlx4/src/buf.c                    |   4 +-
 libmlx4/src/cq.c                     |   4 +-
 libmlx4/src/dbrec.c                  |   4 +-
 libmlx4/src/mlx4.c                   |   4 +-
 libmlx4/src/mlx4.h                   |  42 +---
 libmlx4/src/qp.c                     |   4 +-
 libmlx4/src/srq.c                    |   4 +-
 libmlx4/src/verbs.c                  |   4 +-
 libmlx5/src/buf.c                    |  23 +--
 libmlx5/src/cq.c                     |   5 +-
 libmlx5/src/dbrec.c                  |   4 +-
 libmlx5/src/mlx5.c                   |   8 +-
 libmlx5/src/mlx5.h                   |  40 +---
 libmlx5/src/qp.c                     |   5 +-
 libmlx5/src/srq.c                    |   4 +-
 libmlx5/src/verbs.c                  |  24 +--
 libmthca/src/ah.c                    |   4 +-
 libmthca/src/buf.c                   |  23 +--
 libmthca/src/cq.c                    |   4 +-
 libmthca/src/memfree.c               |   4 +-
 libmthca/src/mthca.c                 |  62 +-----
 libmthca/src/mthca.h                 |  26 +--
 libmthca/src/qp.c                    |   4 +-
 libmthca/src/srq.c                   |   4 +-
 libmthca/src/verbs.c                 |  30 +--
 libnes/src/nes_umain.c               |   2 -
 libnes/src/nes_umain.h               |  17 +-
 libnes/src/nes_uverbs.c              | 359 -----------------------------------
 libocrdma/src/ocrdma_main.c          |   2 -
 libocrdma/src/ocrdma_verbs.c         |  34 +---
 librdmacm/examples/common.h          |  11 +-
 librdmacm/src/acm.c                  |   4 +-
 librdmacm/src/addrinfo.c             |   4 +-
 librdmacm/src/cma.c                  |   4 +-
 librdmacm/src/cma.h                  |  24 +--
 librdmacm/src/indexer.c              |   4 +-
 librdmacm/src/indexer.h              |   4 +-
 librdmacm/src/preload.c              |   4 +-
 librdmacm/src/rsocket.c              |   4 +-
 librxe/src/rxe.c                     |  34 +---
 srp_daemon/srp_daemon/srp_daemon.h   |  22 +--
 88 files changed, 124 insertions(+), 1144 deletions(-)

-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 1/9] Remove HAVE_CONFIG_H
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Steve Wise, Mike Marciniszyn, Dennis Dalessandro,
	Tatyana Nikolova, Sean Hefty, Hal Rosenstock, Doug Ledford,
	Yishai Hadas, Vladimir Sokolovsky, Devesh Sharma, Moni Shoua,
	open list:HF1 USERSPACE PROVIDER for hf1.ko
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

The cmake build system guarantees this header exists, we do not need
the define or the test.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 CMakeLists.txt                      | 2 --
 ibacm/prov/acmp/src/acmp.c          | 4 +---
 ibacm/src/acm.c                     | 4 +---
 ibacm/src/acme.c                    | 4 +---
 ibacm/src/libacm.c                  | 4 +---
 libcxgb3/src/cq.c                   | 4 +---
 libcxgb3/src/iwch.c                 | 4 +---
 libcxgb3/src/qp.c                   | 4 +---
 libcxgb3/src/verbs.c                | 4 +---
 libcxgb4/src/cq.c                   | 4 +---
 libcxgb4/src/dev.c                  | 4 +---
 libcxgb4/src/qp.c                   | 4 +---
 libcxgb4/src/verbs.c                | 4 +---
 libhfi1verbs/src/hfiverbs.c         | 4 +---
 libhfi1verbs/src/verbs.c            | 4 +---
 libi40iw/src/i40iw_umain.c          | 2 --
 libi40iw/src/i40iw_uverbs.c         | 2 --
 libibcm/src/cm.c                    | 4 +---
 libibumad/src/sysfs.c               | 4 +---
 libibumad/src/umad.c                | 4 +---
 libibumad/tests/umad_reg2_compat.c  | 4 +---
 libibumad/tests/umad_register2.c    | 4 +---
 libibverbs/examples/asyncwatch.c    | 4 +---
 libibverbs/examples/device_list.c   | 4 +---
 libibverbs/examples/devinfo.c       | 4 +---
 libibverbs/examples/rc_pingpong.c   | 4 +---
 libibverbs/examples/srq_pingpong.c  | 4 +---
 libibverbs/examples/uc_pingpong.c   | 4 +---
 libibverbs/examples/ud_pingpong.c   | 4 +---
 libibverbs/examples/xsrq_pingpong.c | 4 +---
 libibverbs/src/cmd.c                | 4 +---
 libibverbs/src/compat-1_0.c         | 4 +---
 libibverbs/src/device.c             | 4 +---
 libibverbs/src/init.c               | 4 +---
 libibverbs/src/marshall.c           | 4 +---
 libibverbs/src/memory.c             | 4 +---
 libibverbs/src/sysfs.c              | 4 +---
 libibverbs/src/verbs.c              | 4 +---
 libipathverbs/src/ipathverbs.c      | 4 +---
 libipathverbs/src/verbs.c           | 4 +---
 libmlx4/src/buf.c                   | 4 +---
 libmlx4/src/cq.c                    | 4 +---
 libmlx4/src/dbrec.c                 | 4 +---
 libmlx4/src/mlx4.c                  | 4 +---
 libmlx4/src/qp.c                    | 4 +---
 libmlx4/src/srq.c                   | 4 +---
 libmlx4/src/verbs.c                 | 4 +---
 libmlx5/src/buf.c                   | 4 +---
 libmlx5/src/cq.c                    | 5 +----
 libmlx5/src/dbrec.c                 | 4 +---
 libmlx5/src/mlx5.c                  | 4 +---
 libmlx5/src/qp.c                    | 5 +----
 libmlx5/src/srq.c                   | 4 +---
 libmlx5/src/verbs.c                 | 4 +---
 libmthca/src/ah.c                   | 4 +---
 libmthca/src/buf.c                  | 4 +---
 libmthca/src/cq.c                   | 4 +---
 libmthca/src/memfree.c              | 4 +---
 libmthca/src/mthca.c                | 4 +---
 libmthca/src/qp.c                   | 4 +---
 libmthca/src/srq.c                  | 4 +---
 libmthca/src/verbs.c                | 4 +---
 libnes/src/nes_umain.c              | 2 --
 libnes/src/nes_uverbs.c             | 2 --
 libocrdma/src/ocrdma_main.c         | 2 --
 libocrdma/src/ocrdma_verbs.c        | 2 --
 librdmacm/src/acm.c                 | 4 +---
 librdmacm/src/addrinfo.c            | 4 +---
 librdmacm/src/cma.c                 | 4 +---
 librdmacm/src/cma.h                 | 4 +---
 librdmacm/src/indexer.c             | 4 +---
 librdmacm/src/indexer.h             | 4 +---
 librdmacm/src/preload.c             | 4 +---
 librdmacm/src/rsocket.c             | 4 +---
 librxe/src/rxe.c                    | 4 +---
 75 files changed, 68 insertions(+), 220 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e9e13262899..a6fc092d7994 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,8 +93,6 @@ endif()
 # Setup the basic C compiler
 RDMA_BuildType()
 include_directories(${BUILD_INCLUDE})
-# FIXME: Eliminate HAVE_CONFIG_H, we always have it.
-add_definitions(-DHAVE_CONFIG_H)
 
 # Require GNU99 mode
 RDMA_EnableCStd()
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 75231bfef04f..ed68bd706f76 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -28,9 +28,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdarg.h>
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 41429e1db4d7..146fbff61857 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -28,9 +28,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdarg.h>
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index 4b5fe684c8e2..e96d36ff9fc0 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -28,9 +28,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c
index 3ad1db1d307b..def5b2cf5892 100644
--- a/ibacm/src/libacm.c
+++ b/ibacm/src/libacm.c
@@ -28,9 +28,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <osd.h>
 #include "libacm.h"
diff --git a/libcxgb3/src/cq.c b/libcxgb3/src/cq.c
index a6393d7b4fe3..1510d1e78631 100644
--- a/libcxgb3/src/cq.c
+++ b/libcxgb3/src/cq.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <netinet/in.h>
diff --git a/libcxgb3/src/iwch.c b/libcxgb3/src/iwch.c
index dd0d3711f2e2..aa9b10879d7a 100644
--- a/libcxgb3/src/iwch.c
+++ b/libcxgb3/src/iwch.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libcxgb3/src/qp.c b/libcxgb3/src/qp.c
index 7dd3c7e342a7..30dd898f6e87 100644
--- a/libcxgb3/src/qp.c
+++ b/libcxgb3/src/qp.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libcxgb3/src/verbs.c b/libcxgb3/src/verbs.c
index a2b737f2a192..0cb78d753d41 100644
--- a/libcxgb3/src/verbs.c
+++ b/libcxgb3/src/verbs.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libcxgb4/src/cq.c b/libcxgb4/src/cq.c
index a33d48488967..1ed7dfdb88d4 100644
--- a/libcxgb4/src/cq.c
+++ b/libcxgb4/src/cq.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <syslog.h>
diff --git a/libcxgb4/src/dev.c b/libcxgb4/src/dev.c
index 8c3ecddc6a14..316fc0569f48 100644
--- a/libcxgb4/src/dev.c
+++ b/libcxgb4/src/dev.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libcxgb4/src/qp.c b/libcxgb4/src/qp.c
index 5444137c44bd..3c6d021095fc 100644
--- a/libcxgb4/src/qp.c
+++ b/libcxgb4/src/qp.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <assert.h>
 #include <stdlib.h>
diff --git a/libcxgb4/src/verbs.c b/libcxgb4/src/verbs.c
index aed547dc8ab1..70d250f30701 100644
--- a/libcxgb4/src/verbs.c
+++ b/libcxgb4/src/verbs.c
@@ -29,9 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libhfi1verbs/src/hfiverbs.c b/libhfi1verbs/src/hfiverbs.c
index ced438d1a70b..d2b7dd450992 100644
--- a/libhfi1verbs/src/hfiverbs.c
+++ b/libhfi1verbs/src/hfiverbs.c
@@ -55,9 +55,7 @@
 
 */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libhfi1verbs/src/verbs.c b/libhfi1verbs/src/verbs.c
index e245ad9e5b4f..20d4352094af 100644
--- a/libhfi1verbs/src/verbs.c
+++ b/libhfi1verbs/src/verbs.c
@@ -55,9 +55,7 @@
 
 */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libi40iw/src/i40iw_umain.c b/libi40iw/src/i40iw_umain.c
index ef694a025075..1756e65ee6be 100644
--- a/libi40iw/src/i40iw_umain.c
+++ b/libi40iw/src/i40iw_umain.c
@@ -32,9 +32,7 @@
 *
 *******************************************************************************/
 
-#if HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libi40iw/src/i40iw_uverbs.c b/libi40iw/src/i40iw_uverbs.c
index 8369e10f61ee..3a6799a9b50f 100644
--- a/libi40iw/src/i40iw_uverbs.c
+++ b/libi40iw/src/i40iw_uverbs.c
@@ -32,9 +32,7 @@
 *
 *******************************************************************************/
 
-#if HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libibcm/src/cm.c b/libibcm/src/cm.c
index f5318f01fb61..ebe36bef89e6 100644
--- a/libibcm/src/cm.c
+++ b/libibcm/src/cm.c
@@ -33,9 +33,7 @@
  * $Id$
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/libibumad/src/sysfs.c b/libibumad/src/sysfs.c
index 5d9460851897..d10f312285ea 100644
--- a/libibumad/src/sysfs.c
+++ b/libibumad/src/sysfs.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  *
  */
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <inttypes.h>
 #include <string.h>
diff --git a/libibumad/src/umad.c b/libibumad/src/umad.c
index a7879d385466..176d112e125b 100644
--- a/libibumad/src/umad.c
+++ b/libibumad/src/umad.c
@@ -32,9 +32,7 @@
  *
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <sys/poll.h>
 #include <unistd.h>
diff --git a/libibumad/tests/umad_reg2_compat.c b/libibumad/tests/umad_reg2_compat.c
index 9c239ee4bfae..264882ccc0c1 100644
--- a/libibumad/tests/umad_reg2_compat.c
+++ b/libibumad/tests/umad_reg2_compat.c
@@ -31,9 +31,7 @@
  *
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <string.h>
 #include <stdio.h>
diff --git a/libibumad/tests/umad_register2.c b/libibumad/tests/umad_register2.c
index ed7e816bb63c..7a9b655ae794 100644
--- a/libibumad/tests/umad_register2.c
+++ b/libibumad/tests/umad_register2.c
@@ -31,9 +31,7 @@
  *
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif				/* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <string.h>
 #include <stdio.h>
diff --git a/libibverbs/examples/asyncwatch.c b/libibverbs/examples/asyncwatch.c
index c78994d24bed..7af13bf936ec 100644
--- a/libibverbs/examples/asyncwatch.c
+++ b/libibverbs/examples/asyncwatch.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <endian.h>
diff --git a/libibverbs/examples/device_list.c b/libibverbs/examples/device_list.c
index 70c3af51b6c3..13f40ad63007 100644
--- a/libibverbs/examples/device_list.c
+++ b/libibverbs/examples/device_list.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 
diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c
index e814bacdf7aa..5fd1affa455d 100644
--- a/libibverbs/examples/devinfo.c
+++ b/libibverbs/examples/devinfo.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libibverbs/examples/rc_pingpong.c b/libibverbs/examples/rc_pingpong.c
index 5aa3417c6e23..c92e551c00e6 100644
--- a/libibverbs/examples/rc_pingpong.c
+++ b/libibverbs/examples/rc_pingpong.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libibverbs/examples/srq_pingpong.c b/libibverbs/examples/srq_pingpong.c
index f17972580b57..863ff10dd0f4 100644
--- a/libibverbs/examples/srq_pingpong.c
+++ b/libibverbs/examples/srq_pingpong.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libibverbs/examples/uc_pingpong.c b/libibverbs/examples/uc_pingpong.c
index 7d982d36a5ef..2b105b947cf3 100644
--- a/libibverbs/examples/uc_pingpong.c
+++ b/libibverbs/examples/uc_pingpong.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libibverbs/examples/ud_pingpong.c b/libibverbs/examples/ud_pingpong.c
index deefb9b81013..d0cd73cc0fae 100644
--- a/libibverbs/examples/ud_pingpong.c
+++ b/libibverbs/examples/ud_pingpong.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libibverbs/examples/xsrq_pingpong.c b/libibverbs/examples/xsrq_pingpong.c
index 903548ed6824..c22893e0e721 100644
--- a/libibverbs/examples/xsrq_pingpong.c
+++ b/libibverbs/examples/xsrq_pingpong.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <fcntl.h>
diff --git a/libibverbs/src/cmd.c b/libibverbs/src/cmd.c
index 11f65095b784..06a017b0c9b8 100644
--- a/libibverbs/src/cmd.c
+++ b/libibverbs/src/cmd.c
@@ -32,9 +32,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <unistd.h>
diff --git a/libibverbs/src/compat-1_0.c b/libibverbs/src/compat-1_0.c
index 6b1961d19ede..b286fd73eb01 100644
--- a/libibverbs/src/compat-1_0.c
+++ b/libibverbs/src/compat-1_0.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <string.h>
 #include <stddef.h>
diff --git a/libibverbs/src/device.c b/libibverbs/src/device.c
index cfdf7cfd337c..b4864e3e384b 100644
--- a/libibverbs/src/device.c
+++ b/libibverbs/src/device.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <netinet/in.h>
diff --git a/libibverbs/src/init.c b/libibverbs/src/init.c
index 7ae0fc87d332..779756938a32 100644
--- a/libibverbs/src/init.c
+++ b/libibverbs/src/init.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/libibverbs/src/marshall.c b/libibverbs/src/marshall.c
index 577b4b1ec2f9..a33048404d35 100644
--- a/libibverbs/src/marshall.c
+++ b/libibverbs/src/marshall.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <string.h>
 
diff --git a/libibverbs/src/memory.c b/libibverbs/src/memory.c
index 89509c6e356f..8e728c4f61fc 100644
--- a/libibverbs/src/memory.c
+++ b/libibverbs/src/memory.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <errno.h>
 #include <sys/mman.h>
diff --git a/libibverbs/src/sysfs.c b/libibverbs/src/sysfs.c
index 2e68da4bc97f..d463241ade08 100644
--- a/libibverbs/src/sysfs.c
+++ b/libibverbs/src/sysfs.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libibverbs/src/verbs.c b/libibverbs/src/verbs.c
index debb6f687111..b470ba043658 100644
--- a/libibverbs/src/verbs.c
+++ b/libibverbs/src/verbs.c
@@ -32,9 +32,7 @@
  */
 
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <netinet/in.h>
diff --git a/libipathverbs/src/ipathverbs.c b/libipathverbs/src/ipathverbs.c
index 2ae1689a1131..9a19d0ab98ae 100644
--- a/libipathverbs/src/ipathverbs.c
+++ b/libipathverbs/src/ipathverbs.c
@@ -35,9 +35,7 @@
  * product whatsoever.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libipathverbs/src/verbs.c b/libipathverbs/src/verbs.c
index 578a38af3428..12ca35f32189 100644
--- a/libipathverbs/src/verbs.c
+++ b/libipathverbs/src/verbs.c
@@ -35,9 +35,7 @@
  * product whatsoever.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libmlx4/src/buf.c b/libmlx4/src/buf.c
index c06b3fded82c..9b41e7f62525 100644
--- a/libmlx4/src/buf.c
+++ b/libmlx4/src/buf.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <errno.h>
diff --git a/libmlx4/src/cq.c b/libmlx4/src/cq.c
index 2edbec8e327d..23cc3ed69dc8 100644
--- a/libmlx4/src/cq.c
+++ b/libmlx4/src/cq.c
@@ -32,9 +32,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libmlx4/src/dbrec.c b/libmlx4/src/dbrec.c
index 21ff93664df4..26d696fb94ae 100644
--- a/libmlx4/src/dbrec.c
+++ b/libmlx4/src/dbrec.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmlx4/src/mlx4.c b/libmlx4/src/mlx4.c
index 1757ca325447..326ead4136f8 100644
--- a/libmlx4/src/mlx4.c
+++ b/libmlx4/src/mlx4.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libmlx4/src/qp.c b/libmlx4/src/qp.c
index 1b730bfea4b8..4b5acd71108e 100644
--- a/libmlx4/src/qp.c
+++ b/libmlx4/src/qp.c
@@ -32,9 +32,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmlx4/src/srq.c b/libmlx4/src/srq.c
index 28bc2d41cdce..c0e028671828 100644
--- a/libmlx4/src/srq.c
+++ b/libmlx4/src/srq.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmlx4/src/verbs.c b/libmlx4/src/verbs.c
index 5cc82cf38763..50a44340639b 100644
--- a/libmlx4/src/verbs.c
+++ b/libmlx4/src/verbs.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libmlx5/src/buf.c b/libmlx5/src/buf.c
index 1a681c6a3eaf..7e06095d0352 100644
--- a/libmlx5/src/buf.c
+++ b/libmlx5/src/buf.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <signal.h>
 #include <sys/ipc.h>
diff --git a/libmlx5/src/cq.c b/libmlx5/src/cq.c
index 5ad076c40d91..2a53c897706f 100644
--- a/libmlx5/src/cq.c
+++ b/libmlx5/src/cq.c
@@ -30,10 +30,7 @@
  * SOFTWARE.
  */
 
-
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libmlx5/src/dbrec.c b/libmlx5/src/dbrec.c
index dbc0e650b6f4..3af81124ed95 100644
--- a/libmlx5/src/dbrec.c
+++ b/libmlx5/src/dbrec.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmlx5/src/mlx5.c b/libmlx5/src/mlx5.c
index 058b52fcd5f6..121a833062f1 100644
--- a/libmlx5/src/mlx5.c
+++ b/libmlx5/src/mlx5.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libmlx5/src/qp.c b/libmlx5/src/qp.c
index 9363fddc3f3c..04abe1588d6e 100644
--- a/libmlx5/src/qp.c
+++ b/libmlx5/src/qp.c
@@ -30,10 +30,7 @@
  * SOFTWARE.
  */
 
-
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmlx5/src/srq.c b/libmlx5/src/srq.c
index 24979bfb69ab..a06afa3a5931 100644
--- a/libmlx5/src/srq.c
+++ b/libmlx5/src/srq.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmlx5/src/verbs.c b/libmlx5/src/verbs.c
index 4be602be8025..58673f4433fd 100644
--- a/libmlx5/src/verbs.c
+++ b/libmlx5/src/verbs.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libmthca/src/ah.c b/libmthca/src/ah.c
index d7494d57f960..e83d66527839 100644
--- a/libmthca/src/ah.c
+++ b/libmthca/src/ah.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmthca/src/buf.c b/libmthca/src/buf.c
index 074a5f8dc710..78e7b89c4db5 100644
--- a/libmthca/src/buf.c
+++ b/libmthca/src/buf.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <sys/mman.h>
diff --git a/libmthca/src/cq.c b/libmthca/src/cq.c
index 8b4a6a862d1a..d71d430c6e28 100644
--- a/libmthca/src/cq.c
+++ b/libmthca/src/cq.c
@@ -32,9 +32,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libmthca/src/memfree.c b/libmthca/src/memfree.c
index 87de4c0f5899..77a80e24b95f 100644
--- a/libmthca/src/memfree.c
+++ b/libmthca/src/memfree.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmthca/src/mthca.c b/libmthca/src/mthca.c
index e33bf7ff8559..d6bda2d29d66 100644
--- a/libmthca/src/mthca.c
+++ b/libmthca/src/mthca.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libmthca/src/qp.c b/libmthca/src/qp.c
index 84dd206d9125..715ca65e9bd6 100644
--- a/libmthca/src/qp.c
+++ b/libmthca/src/qp.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmthca/src/srq.c b/libmthca/src/srq.c
index 97a0c743f5f7..ff6f532733f4 100644
--- a/libmthca/src/srq.c
+++ b/libmthca/src/srq.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <netinet/in.h>
diff --git a/libmthca/src/verbs.c b/libmthca/src/verbs.c
index b6782c9865eb..b3bce82affae 100644
--- a/libmthca/src/verbs.c
+++ b/libmthca/src/verbs.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libnes/src/nes_umain.c b/libnes/src/nes_umain.c
index 16ce3f13c702..b4e0bc136160 100644
--- a/libnes/src/nes_umain.c
+++ b/libnes/src/nes_umain.c
@@ -31,9 +31,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
 #include <config.h>
-#endif				/* HAVE_CONFIG_H */
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libnes/src/nes_uverbs.c b/libnes/src/nes_uverbs.c
index 983d87a80b8b..7c2454e7f55a 100644
--- a/libnes/src/nes_uverbs.c
+++ b/libnes/src/nes_uverbs.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
 #include <config.h>
-#endif				/* HAVE_CONFIG_H */
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libocrdma/src/ocrdma_main.c b/libocrdma/src/ocrdma_main.c
index 064ecb318c4c..f3830d9fc5d3 100644
--- a/libocrdma/src/ocrdma_main.c
+++ b/libocrdma/src/ocrdma_main.c
@@ -32,9 +32,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if HAVE_CONFIG_H
 #include <config.h>
-#endif				/* HAVE_CONFIG_H */
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/libocrdma/src/ocrdma_verbs.c b/libocrdma/src/ocrdma_verbs.c
index 628e4bf18b43..6d58cb219fe1 100644
--- a/libocrdma/src/ocrdma_verbs.c
+++ b/libocrdma/src/ocrdma_verbs.c
@@ -32,9 +32,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#if HAVE_CONFIG_H
 #include <config.h>
-#endif				/* HAVE_CONFIG_H */
 
 #include <assert.h>
 #include <stdlib.h>
diff --git a/librdmacm/src/acm.c b/librdmacm/src/acm.c
index 823381aac367..ad6706b2592e 100644
--- a/librdmacm/src/acm.c
+++ b/librdmacm/src/acm.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <inttypes.h>
diff --git a/librdmacm/src/addrinfo.c b/librdmacm/src/addrinfo.c
index 046b8be11be1..2f4e674e1ebb 100644
--- a/librdmacm/src/addrinfo.c
+++ b/librdmacm/src/addrinfo.c
@@ -32,9 +32,7 @@
  * $Id: cm.c 3453 2005-09-15 21:43:21Z sean.hefty $
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
diff --git a/librdmacm/src/cma.c b/librdmacm/src/cma.c
index a89e663bcaab..77f6fea38c6b 100644
--- a/librdmacm/src/cma.c
+++ b/librdmacm/src/cma.c
@@ -30,9 +30,7 @@
  * SOFTWARE.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/librdmacm/src/cma.h b/librdmacm/src/cma.h
index ce428deba849..d6005538227f 100644
--- a/librdmacm/src/cma.h
+++ b/librdmacm/src/cma.h
@@ -34,9 +34,7 @@
 #if !defined(CMA_H)
 #define CMA_H
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdlib.h>
 #include <errno.h>
diff --git a/librdmacm/src/indexer.c b/librdmacm/src/indexer.c
index be2e69c895c2..00be7d04cc93 100644
--- a/librdmacm/src/indexer.c
+++ b/librdmacm/src/indexer.c
@@ -31,9 +31,7 @@
  *
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <errno.h>
 #include <sys/types.h>
diff --git a/librdmacm/src/indexer.h b/librdmacm/src/indexer.h
index 0c5f3882673f..2d1e46ecabd4 100644
--- a/librdmacm/src/indexer.h
+++ b/librdmacm/src/indexer.h
@@ -34,9 +34,7 @@
 #if !defined(INDEXER_H)
 #define INDEXER_H
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <sys/types.h>
 
diff --git a/librdmacm/src/preload.c b/librdmacm/src/preload.c
index 2a90f79b226c..cf258bf8eb3a 100644
--- a/librdmacm/src/preload.c
+++ b/librdmacm/src/preload.c
@@ -31,9 +31,7 @@
  *
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
diff --git a/librdmacm/src/rsocket.c b/librdmacm/src/rsocket.c
index 488d44fb3654..7e7a38ee82b6 100644
--- a/librdmacm/src/rsocket.c
+++ b/librdmacm/src/rsocket.c
@@ -31,9 +31,7 @@
  *
  */
 #define _GNU_SOURCE
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
diff --git a/librxe/src/rxe.c b/librxe/src/rxe.c
index 7164f6627171..6bd04d696c41 100644
--- a/librxe/src/rxe.c
+++ b/librxe/src/rxe.c
@@ -37,9 +37,7 @@
  * product whatsoever.
  */
 
-#if HAVE_CONFIG_H
-#  include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
 
 #include <stdio.h>
 #include <stdlib.h>
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 2/9] Remove HAVE_VALGRIND_MEMCHECK_H/INCLUDE_VALGRIND
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Sean Hefty, Hal Rosenstock, Doug Ledford, Yishai Hadas,
	Vladimir Sokolovsky, Bart Van Assche
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

The cmake build system guarantees that valgrind/memcheck.h is present.
If the system does not have it, or valgrind is disabled, then it is
replaced with a dummy header full of empty stubs.

Thus all the copy&paste boiler plate is consolidated into buildlib.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 buildlib/config.h.in               |  4 ----
 libibcm/src/cm.c                   | 11 +----------
 libibumad/src/umad.c               | 14 +-------------
 libibverbs/src/ibverbs.h           | 14 +-------------
 libmlx4/src/mlx4.h                 | 18 +-----------------
 libmlx5/src/mlx5.h                 | 18 +-----------------
 libmthca/src/mthca.h               | 18 +-----------------
 librdmacm/src/cma.h                | 11 +----------
 srp_daemon/srp_daemon/srp_daemon.h |  5 -----
 9 files changed, 7 insertions(+), 106 deletions(-)

diff --git a/buildlib/config.h.in b/buildlib/config.h.in
index 0a87457e6d7a..a02be9cfb0f7 100644
--- a/buildlib/config.h.in
+++ b/buildlib/config.h.in
@@ -21,10 +21,6 @@
 // FIXME: Remove this, The cmake version hard-requires new style CLOEXEC support
 #define STREAM_CLOEXEC "e"
 
-// FIXME: Remove this, cmake always provides a valgrind/memcheck.h
-#define HAVE_VALGRIND_MEMCHECK_H 1
-#define INCLUDE_VALGRIND 1
-
 #define IBV_CONFIG_DIR "@CONFIG_DIR@"
 #define RS_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket"
 #define IWPM_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/iwpmd.conf"
diff --git a/libibcm/src/cm.c b/libibcm/src/cm.c
index ebe36bef89e6..f775923aa73c 100644
--- a/libibcm/src/cm.c
+++ b/libibcm/src/cm.c
@@ -49,16 +49,7 @@
 #include <infiniband/driver.h>
 #include <infiniband/marshall.h>
 
-#ifdef INCLUDE_VALGRIND
-#   include <valgrind/memcheck.h>
-#   ifndef VALGRIND_MAKE_MEM_DEFINED
-#       warning "Valgrind requested, but VALGRIND_MAKE_MEM_DEFINED undefined"
-#   endif
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-#   define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
+#include <valgrind/memcheck.h>
 
 #define PFX "libibcm: "
 
diff --git a/libibumad/src/umad.c b/libibumad/src/umad.c
index 176d112e125b..0c969f1eb8ad 100644
--- a/libibumad/src/umad.c
+++ b/libibumad/src/umad.c
@@ -52,19 +52,7 @@
 
 #define IB_OPENIB_OUI                 (0x001405)
 
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-#  include <valgrind/memcheck.h>
-
-#  ifndef VALGRIND_MAKE_MEM_DEFINED
-#    warning "Valgrind support requested, but VALGRIND_MAKE_MEM_DEFINED not available"
-#  endif
-
-#endif				/* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-#  define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
+#include <valgrind/memcheck.h>
 
 typedef struct ib_user_mad_reg_req {
 	uint32_t id;
diff --git a/libibverbs/src/ibverbs.h b/libibverbs/src/ibverbs.h
index 062a490915b0..7892af4ad247 100644
--- a/libibverbs/src/ibverbs.h
+++ b/libibverbs/src/ibverbs.h
@@ -38,19 +38,7 @@
 
 #include <infiniband/driver.h>
 
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-#  include <valgrind/memcheck.h>
-
-#  ifndef VALGRIND_MAKE_MEM_DEFINED
-#    warning "Valgrind support requested, but VALGRIND_MAKE_MEM_DEFINED not available"
-#  endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-#  define VALGRIND_MAKE_MEM_DEFINED(addr, len) 0
-#endif
+#include <valgrind/memcheck.h>
 
 #define HIDDEN		__attribute__((visibility ("hidden")))
 
diff --git a/libmlx4/src/mlx4.h b/libmlx4/src/mlx4.h
index feea3386f9a7..4551141d2007 100644
--- a/libmlx4/src/mlx4.h
+++ b/libmlx4/src/mlx4.h
@@ -47,23 +47,7 @@
 #define uninitialized_var(x) x = x
 #endif
 
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-#  include <valgrind/memcheck.h>
-
-#  if !defined(VALGRIND_MAKE_MEM_DEFINED) || !defined(VALGRIND_MAKE_MEM_UNDEFINED)
-#    warning "Valgrind support requested, but VALGRIND_MAKE_MEM_(UN)DEFINED not available"
-#  endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-#  define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_UNDEFINED
-#  define VALGRIND_MAKE_MEM_UNDEFINED(addr,len)
-#endif
+#include <valgrind/memcheck.h>
 
 #ifndef rmb
 #  define rmb() mb()
diff --git a/libmlx5/src/mlx5.h b/libmlx5/src/mlx5.h
index 6c4e83002028..aa8b6feceb4e 100644
--- a/libmlx5/src/mlx5.h
+++ b/libmlx5/src/mlx5.h
@@ -52,23 +52,7 @@
 #define uninitialized_var(x) x = x
 #endif
 
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-#  include <valgrind/memcheck.h>
-
-#  if !defined(VALGRIND_MAKE_MEM_DEFINED) || !defined(VALGRIND_MAKE_MEM_UNDEFINED)
-#    warning "Valgrind support requested, but VALGRIND_MAKE_MEM_(UN)DEFINED not available"
-#  endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-#  define VALGRIND_MAKE_MEM_DEFINED(addr, len)
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_UNDEFINED
-#  define VALGRIND_MAKE_MEM_UNDEFINED(addr, len)
-#endif
+#include <valgrind/memcheck.h>
 
 #ifndef rmb
 #  define rmb() mb()
diff --git a/libmthca/src/mthca.h b/libmthca/src/mthca.h
index bd1e7a2b1dc0..18d52291343f 100644
--- a/libmthca/src/mthca.h
+++ b/libmthca/src/mthca.h
@@ -39,23 +39,7 @@
 #include <infiniband/driver.h>
 #include <infiniband/arch.h>
 
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-#  include <valgrind/memcheck.h>
-
-#  if !defined(VALGRIND_MAKE_MEM_DEFINED) || !defined(VALGRIND_MAKE_MEM_UNDEFINED)
-#    warning "Valgrind support requested, but VALGRIND_MAKE_MEM_(UN)DEFINED not available"
-#  endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-#  define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_UNDEFINED
-#  define VALGRIND_MAKE_MEM_UNDEFINED(addr,len)
-#endif
+#include <valgrind/memcheck.h>
 
 #ifndef rmb
 #  define rmb() mb()
diff --git a/librdmacm/src/cma.h b/librdmacm/src/cma.h
index d6005538227f..16a55a67af9e 100644
--- a/librdmacm/src/cma.h
+++ b/librdmacm/src/cma.h
@@ -47,16 +47,7 @@
 
 #include <ccan/minmax.h>
 
-#ifdef INCLUDE_VALGRIND
-#   include <valgrind/memcheck.h>
-#   ifndef VALGRIND_MAKE_MEM_DEFINED
-#       warning "Valgrind requested, but VALGRIND_MAKE_MEM_DEFINED undefined"
-#   endif
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-#   define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
+#include <valgrind/memcheck.h>
 
 #define PFX "librdmacm: "
 
diff --git a/srp_daemon/srp_daemon/srp_daemon.h b/srp_daemon/srp_daemon/srp_daemon.h
index 6d1575519bc3..d6a2d8a84728 100644
--- a/srp_daemon/srp_daemon/srp_daemon.h
+++ b/srp_daemon/srp_daemon/srp_daemon.h
@@ -408,12 +408,7 @@ typedef struct {
 	char filler[MAD_BLOCK_SIZE];
 } srp_ib_user_mad_t;
 
-#if defined(HAVE_VALGRIND_DRD_H) && defined(ENABLE_VALGRIND)
 #include <valgrind/drd.h>
-#endif
-#ifndef ANNOTATE_BENIGN_RACE_SIZED
-#define ANNOTATE_BENIGN_RACE_SIZED(a, b, c) do { } while(0)
-#endif
 
 #define pr_human(arg...)				\
 	do {						\
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 3/9] Remove HAVE_IBV_*
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Mike Marciniszyn, Dennis Dalessandro, Yishai Hadas,
	Vladimir Sokolovsky, Moni Shoua,
	open list:HF1 USERSPACE PROVIDER for hf1.ko
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

These were used to support building provider plugins against old
versions of libibverbs. Since libibverbs is now included together
with the provider that is no longer possible or supported.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 buildlib/config.h.in           |  6 -----
 libhfi1verbs/src/hfiverbs.c    | 18 -------------
 libipathverbs/src/ipathverbs.c | 18 -------------
 libmlx5/src/buf.c              | 19 --------------
 libmlx5/src/mlx5.c             |  4 ---
 libmlx5/src/verbs.c            |  2 --
 libmthca/src/buf.c             | 19 --------------
 libmthca/src/mthca.c           | 58 ------------------------------------------
 librxe/src/rxe.c               | 14 ----------
 9 files changed, 158 deletions(-)

diff --git a/buildlib/config.h.in b/buildlib/config.h.in
index a02be9cfb0f7..3b94ea3e4f51 100644
--- a/buildlib/config.h.in
+++ b/buildlib/config.h.in
@@ -1,12 +1,6 @@
 #ifndef CONFIG_H_IN
 #define CONFIG_H_IN
 
-// FIXME: Remove this, ibverbs is included so we don't need to detect
-#define HAVE_IBV_DOFORK_RANGE 1
-#define HAVE_IBV_DONTFORK_RANGE 1
-#define HAVE_IBV_REGISTER_DRIVER 1
-#define HAVE_IBV_READ_SYSFS_FILE 1
-
 #define HAVE_STATEMENT_EXPR 1
 #define HAVE_BUILTIN_TYPES_COMPATIBLE_P 1
 #define HAVE_TYPEOF 1
diff --git a/libhfi1verbs/src/hfiverbs.c b/libhfi1verbs/src/hfiverbs.c
index d2b7dd450992..e28afc7fcc89 100644
--- a/libhfi1verbs/src/hfiverbs.c
+++ b/libhfi1verbs/src/hfiverbs.c
@@ -217,25 +217,7 @@ found:
 	return &dev->ibv_dev;
 }
 
-#ifdef HAVE_IBV_REGISTER_DRIVER
 static __attribute__((constructor)) void hfi1_register_driver(void)
 {
 	ibv_register_driver("hfi1verbs", hfi1_driver_init);
 }
-#else
-/*
- * Export the old libsysfs sysfs_class_device-based driver entry point
- * if libibverbs does not export an ibv_register_driver() function.
- */
-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
-{
-        int abi_ver = 0;
-        char value[8];
-
-        if (ibv_read_sysfs_file(sysdev->path, "abi_version",
-                                value, sizeof value) > 0)
-                abi_ver = strtol(value, NULL, 10);
-
-        return hfi1_driver_init(sysdev->path, abi_ver);
-}
-#endif /* HAVE_IBV_REGISTER_DRIVER */
diff --git a/libipathverbs/src/ipathverbs.c b/libipathverbs/src/ipathverbs.c
index 9a19d0ab98ae..4b945f6c58ec 100644
--- a/libipathverbs/src/ipathverbs.c
+++ b/libipathverbs/src/ipathverbs.c
@@ -216,25 +216,7 @@ found:
 	return &dev->ibv_dev;
 }
 
-#ifdef HAVE_IBV_REGISTER_DRIVER
 static __attribute__((constructor)) void ipath_register_driver(void)
 {
 	ibv_register_driver("ipathverbs", ipath_driver_init);
 }
-#else
-/*
- * Export the old libsysfs sysfs_class_device-based driver entry point
- * if libibverbs does not export an ibv_register_driver() function.
- */
-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
-{
-        int abi_ver = 0;
-        char value[8];
-
-        if (ibv_read_sysfs_file(sysdev->path, "abi_version",
-                                value, sizeof value) > 0)
-                abi_ver = strtol(value, NULL, 10);
-
-        return ipath_driver_init(sysdev->path, abi_ver);
-}
-#endif /* HAVE_IBV_REGISTER_DRIVER */
diff --git a/libmlx5/src/buf.c b/libmlx5/src/buf.c
index 7e06095d0352..853450ae93b3 100644
--- a/libmlx5/src/buf.c
+++ b/libmlx5/src/buf.c
@@ -42,25 +42,6 @@
 #include "mlx5.h"
 #include "bitmap.h"
 
-#if !(defined(HAVE_IBV_DONTFORK_RANGE) && defined(HAVE_IBV_DOFORK_RANGE))
-
-/*
- * If libibverbs isn't exporting these functions, then there's no
- * point in doing it here, because the rest of libibverbs isn't going
- * to be fork-safe anyway.
- */
-static int ibv_dontfork_range(void *base, size_t size)
-{
-	return 0;
-}
-
-static int ibv_dofork_range(void *base, size_t size)
-{
-	return 0;
-}
-
-#endif /* HAVE_IBV_DONTFORK_RANGE && HAVE_IBV_DOFORK_RANGE */
-
 static int mlx5_bitmap_init(struct mlx5_bitmap *bitmap, uint32_t num,
 			    uint32_t mask)
 {
diff --git a/libmlx5/src/mlx5.c b/libmlx5/src/mlx5.c
index 121a833062f1..f24e5043dfe6 100644
--- a/libmlx5/src/mlx5.c
+++ b/libmlx5/src/mlx5.c
@@ -42,10 +42,6 @@
 #include <sched.h>
 #include <sys/param.h>
 
-#ifndef HAVE_IBV_REGISTER_DRIVER
-#include <sysfs/libsysfs.h>
-#endif
-
 #include "mlx5.h"
 #include "mlx5-abi.h"
 
diff --git a/libmlx5/src/verbs.c b/libmlx5/src/verbs.c
index 58673f4433fd..acbabc814621 100644
--- a/libmlx5/src/verbs.c
+++ b/libmlx5/src/verbs.c
@@ -993,9 +993,7 @@ static const char *qptype2key(enum ibv_qp_type type)
 	case IBV_QPT_RC: return "HUGE_RC";
 	case IBV_QPT_UC: return "HUGE_UC";
 	case IBV_QPT_UD: return "HUGE_UD";
-#ifdef _NOT_EXISTS_IN_OFED_2_0
 	case IBV_QPT_RAW_PACKET: return "HUGE_RAW_ETH";
-#endif
 	default: return "HUGE_NA";
 	}
 }
diff --git a/libmthca/src/buf.c b/libmthca/src/buf.c
index 78e7b89c4db5..c03ee1f9a3e4 100644
--- a/libmthca/src/buf.c
+++ b/libmthca/src/buf.c
@@ -38,25 +38,6 @@
 
 #include "mthca.h"
 
-#if !(defined(HAVE_IBV_DONTFORK_RANGE) && defined(HAVE_IBV_DOFORK_RANGE))
-
-/*
- * If libibverbs isn't exporting these functions, then there's no
- * point in doing it here, because the rest of libibverbs isn't going
- * to be fork-safe anyway.
- */
-static int ibv_dontfork_range(void *base, size_t size)
-{
-	return 0;
-}
-
-static int ibv_dofork_range(void *base, size_t size)
-{
-	return 0;
-}
-
-#endif /* HAVE_IBV_DONTFORK_RANGE && HAVE_IBV_DOFORK_RANGE */
-
 int mthca_alloc_buf(struct mthca_buf *buf, size_t size, int page_size)
 {
 	int ret;
diff --git a/libmthca/src/mthca.c b/libmthca/src/mthca.c
index d6bda2d29d66..d5660ceef7e0 100644
--- a/libmthca/src/mthca.c
+++ b/libmthca/src/mthca.c
@@ -41,16 +41,6 @@
 #include <pthread.h>
 #include <string.h>
 
-#ifndef HAVE_IBV_REGISTER_DRIVER
-#include <sysfs/libsysfs.h>
-#endif
-
-#ifndef HAVE_IBV_READ_SYSFS_FILE
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#endif
-
 #include "mthca.h"
 #include "mthca-abi.h"
 
@@ -224,36 +214,6 @@ static struct ibv_device_ops mthca_dev_ops = {
 	.free_context  = mthca_free_context
 };
 
-/*
- * Keep a private implementation of HAVE_IBV_READ_SYSFS_FILE to handle
- * old versions of libibverbs that didn't implement it.  This can be
- * removed when libibverbs 1.0.3 or newer is available "everywhere."
- */
-#ifndef HAVE_IBV_READ_SYSFS_FILE
-static int ibv_read_sysfs_file(const char *dir, const char *file,
-			       char *buf, size_t size)
-{
-	char path[256];
-	int fd;
-	int len;
-
-	snprintf(path, sizeof path, "%s/%s", dir, file);
-
-	fd = open(path, O_RDONLY);
-	if (fd < 0)
-		return -1;
-
-	len = read(fd, buf, size);
-
-	close(fd);
-
-	if (len > 0 && buf[len - 1] == '\n')
-		buf[--len] = '\0';
-
-	return len;
-}
-#endif /* HAVE_IBV_READ_SYSFS_FILE */
-
 static struct ibv_device *mthca_driver_init(const char *uverbs_sys_path,
 					    int abi_version)
 {
@@ -300,25 +260,7 @@ found:
 	return &dev->ibv_dev;
 }
 
-#ifdef HAVE_IBV_REGISTER_DRIVER
 static __attribute__((constructor)) void mthca_register_driver(void)
 {
 	ibv_register_driver("mthca", mthca_driver_init);
 }
-#else
-/*
- * Export the old libsysfs sysfs_class_device-based driver entry point
- * if libibverbs does not export an ibv_register_driver() function.
- */
-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
-{
-	int abi_ver = 0;
-	char value[8];
-
-	if (ibv_read_sysfs_file(sysdev->path, "abi_version",
-				value, sizeof value) > 0)
-		abi_ver = strtol(value, NULL, 10);
-
-	return mthca_driver_init(sysdev->path, abi_ver);
-}
-#endif /* HAVE_IBV_REGISTER_DRIVER */
diff --git a/librxe/src/rxe.c b/librxe/src/rxe.c
index 6bd04d696c41..ef7434e1d506 100644
--- a/librxe/src/rxe.c
+++ b/librxe/src/rxe.c
@@ -935,22 +935,8 @@ static struct ibv_device *rxe_driver_init(const char *uverbs_sys_path,
 	return &dev->ibv_dev;
 }
 
-#ifdef HAVE_IBV_REGISTER_DRIVER
 static __attribute__ ((constructor))
 void rxe_register_driver(void)
 {
 	ibv_register_driver("rxe", rxe_driver_init);
 }
-#else
-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
-{
-	int abi_ver = 0;
-	char value[8];
-
-	if (ibv_read_sysfs_file(sysdev->path, "abi_version",
-				value, sizeof value) > 0)
-		abi_ver = strtol(value, NULL, 10);
-
-	return rxe_driver_init(sysdev->path, abi_ver);
-}
-#endif /* HAVE_IBV_REGISTER_DRIVER */
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 4/9] Do not use IBV_CMD_(REG_MR|RESIZE_CQ)_HAS_RESP_PARAMS
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Mike Marciniszyn, Dennis Dalessandro, Tatyana Nikolova,
	Yishai Hadas, Vladimir Sokolovsky, Moni Shoua,
	open list:HF1 USERSPACE PROVIDER for hf1.ko
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

These were used to support building provider plugins against old
versions of libibverbs. Since libibverbs is now included together
with the provider that is no longer possible or supported.

The define is kept as it is in a public header.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 libhfi1verbs/src/verbs.c    | 15 +++------------
 libi40iw/src/i40iw_uverbs.c | 26 --------------------------
 libipathverbs/src/verbs.c   | 16 +++-------------
 libmlx5/src/verbs.c         | 18 ++++--------------
 libmthca/src/verbs.c        | 26 ++++++--------------------
 libnes/src/nes_uverbs.c     | 35 -----------------------------------
 librxe/src/rxe.c            | 16 +++-------------
 7 files changed, 19 insertions(+), 133 deletions(-)

diff --git a/libhfi1verbs/src/verbs.c b/libhfi1verbs/src/verbs.c
index 20d4352094af..06ddbb712857 100644
--- a/libhfi1verbs/src/verbs.c
+++ b/libhfi1verbs/src/verbs.c
@@ -135,24 +135,15 @@ struct ibv_mr *hfi1_reg_mr(struct ibv_pd *pd, void *addr,
 {
 	struct ibv_mr *mr;
 	struct ibv_reg_mr cmd;
+	struct ibv_reg_mr_resp resp;
 	int ret;
 
 	mr = malloc(sizeof *mr);
 	if (!mr)
 		return NULL;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
-	{
-		struct ibv_reg_mr_resp resp;
-
-		ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
-				     access, mr, &cmd, sizeof cmd,
-                                     &resp, sizeof resp);
-	}
-#else
-	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr,
-			     access, mr, &cmd, sizeof cmd);
-#endif
+	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr,
+			     &cmd, sizeof cmd, &resp, sizeof resp);
 
 	if (ret) {
 		free(mr);
diff --git a/libi40iw/src/i40iw_uverbs.c b/libi40iw/src/i40iw_uverbs.c
index 3a6799a9b50f..a117b534f533 100644
--- a/libi40iw/src/i40iw_uverbs.c
+++ b/libi40iw/src/i40iw_uverbs.c
@@ -154,9 +154,7 @@ struct ibv_mr *i40iw_ureg_mr(struct ibv_pd *pd, void *addr, size_t length, int a
 {
 	struct ibv_mr *mr;
 	struct i40iw_ureg_mr cmd;
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	struct ibv_reg_mr_resp resp;
-#endif
 
 	mr = malloc(sizeof(*mr));
 	if (!mr)
@@ -164,14 +162,9 @@ struct ibv_mr *i40iw_ureg_mr(struct ibv_pd *pd, void *addr, size_t length, int a
 
 	cmd.reg_type = I40IW_UMEMREG_TYPE_MEM;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr,
 			   access, mr, &cmd.ibv_cmd, sizeof(cmd),
 			   &resp, sizeof(resp))) {
-#else
-	if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr,
-			   access, mr, &cmd.ibv_cmd, sizeof(cmd))) {
-#endif
 		fprintf(stderr, PFX "%s: Failed to register memory\n", __func__);
 		free(mr);
 		return NULL;
@@ -226,9 +219,7 @@ struct ibv_cq *i40iw_ucreate_cq(struct ibv_context *context, int cqe,
 
 	struct i40iw_ureg_mr reg_mr_cmd;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	struct ibv_reg_mr_resp reg_mr_resp;
-#endif
 
 	if (cqe > I40IW_MAX_CQ_SIZE)
 		return NULL;
@@ -268,18 +259,10 @@ struct ibv_cq *i40iw_ucreate_cq(struct ibv_context *context, int cqe,
 
 	reg_mr_cmd.cq_pages = cq_pages;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	ret = ibv_cmd_reg_mr(&iwvctx->iwupd->ibv_pd, (void *)info.cq_base, totalsize,
 			     (uintptr_t)info.cq_base, IBV_ACCESS_LOCAL_WRITE,
 			     &iwucq->mr, &reg_mr_cmd.ibv_cmd, sizeof(reg_mr_cmd), &reg_mr_resp,
 			     sizeof(reg_mr_resp));
-#else
-	ret = ibv_cmd_reg_mr(&iwvctx->iwupd->ibv_pd, (void *)info.sq, totalsize,
-			     (uintptr_t)info.cq_base, IBV_ACCESS_LOCAL_WRITE,
-			     &iwucq->mr, &reg_mr_cmd.ibv_cmd,
-			     sizeof(reg_mr_cmd));
-#endif
-
 	if (ret) {
 		fprintf(stderr, PFX "%s: failed to pin memory for CQ\n", __func__);
 		goto err;
@@ -509,10 +492,7 @@ static int i40iw_vmapped_qp(struct i40iw_uqp *iwuqp, struct ibv_pd *pd,
 	int ret;
 	struct i40iw_ureg_mr reg_mr_cmd;
 	u32 sq_pages, rq_pages;
-
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	struct ibv_reg_mr_resp reg_mr_resp;
-#endif
 
 	memset(&reg_mr_cmd, 0, sizeof(reg_mr_cmd));
 	if ((sqdepth % I40IWQP_SW_WQSIZE_1024))
@@ -540,15 +520,9 @@ static int i40iw_vmapped_qp(struct i40iw_uqp *iwuqp, struct ibv_pd *pd,
 	reg_mr_cmd.sq_pages = sq_pages;
 	reg_mr_cmd.rq_pages = rq_pages;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	ret = ibv_cmd_reg_mr(pd, (void *)info->sq, totalqpsize, (uintptr_t)info->sq,
 			     IBV_ACCESS_LOCAL_WRITE, &iwuqp->mr, &reg_mr_cmd.ibv_cmd,
 			     sizeof(reg_mr_cmd), &reg_mr_resp, sizeof(reg_mr_resp));
-#else
-	ret = ibv_cmd_reg_mr(pd, (void *)info->sq, totalqpsize, (uintptr_t)info->sq,
-			     IBV_ACCESS_LOCAL_WRITE, &iwuqp->mr, &reg_mr_cmd.ibv_cmd,
-			     sizeof(reg_mr_cmd));
-#endif
 	if (ret) {
 		fprintf(stderr, PFX "%s: failed to pin memory for SQ\n", __func__);
 		free(info->sq);
diff --git a/libipathverbs/src/verbs.c b/libipathverbs/src/verbs.c
index 12ca35f32189..35b2162a84f0 100644
--- a/libipathverbs/src/verbs.c
+++ b/libipathverbs/src/verbs.c
@@ -115,25 +115,15 @@ struct ibv_mr *ipath_reg_mr(struct ibv_pd *pd, void *addr,
 {
 	struct ibv_mr *mr;
 	struct ibv_reg_mr cmd;
+	struct ibv_reg_mr_resp resp;
 	int ret;
 
 	mr = malloc(sizeof *mr);
 	if (!mr)
 		return NULL;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
-	{
-		struct ibv_reg_mr_resp resp;
-
-		ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
-				     access, mr, &cmd, sizeof cmd,
-                                     &resp, sizeof resp);
-	}
-#else
-	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr,
-			     access, mr, &cmd, sizeof cmd);
-#endif
-
+	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr,
+			     &cmd, sizeof cmd, &resp, sizeof resp);
 	if (ret) {
 		free(mr);
 		return NULL;
diff --git a/libmlx5/src/verbs.c b/libmlx5/src/verbs.c
index acbabc814621..ef85a63637c9 100644
--- a/libmlx5/src/verbs.c
+++ b/libmlx5/src/verbs.c
@@ -171,25 +171,15 @@ struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
 	struct ibv_reg_mr cmd;
 	int ret;
 	enum ibv_access_flags access = (enum ibv_access_flags)acc;
+	struct ibv_reg_mr_resp resp;
 
 	mr = calloc(1, sizeof(*mr));
 	if (!mr)
 		return NULL;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
-	{
-		struct ibv_reg_mr_resp resp;
-
-		ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
-				     access, &(mr->ibv_mr),
-				     &cmd, sizeof(cmd),
-				     &resp, sizeof resp);
-	}
-#else
-	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, access,
-			      &(mr->ibv_mr),
-			     &cmd, sizeof cmd);
-#endif
+	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access,
+			     &(mr->ibv_mr), &cmd, sizeof(cmd), &resp,
+			     sizeof resp);
 	if (ret) {
 		mlx5_free_buf(&(mr->buf));
 		free(mr);
diff --git a/libmthca/src/verbs.c b/libmthca/src/verbs.c
index b3bce82affae..60dd44002ea3 100644
--- a/libmthca/src/verbs.c
+++ b/libmthca/src/verbs.c
@@ -120,6 +120,7 @@ static struct ibv_mr *__mthca_reg_mr(struct ibv_pd *pd, void *addr,
 {
 	struct ibv_mr *mr;
 	struct mthca_reg_mr cmd;
+	struct ibv_reg_mr_resp resp;
 	int ret;
 
 	/*
@@ -135,17 +136,8 @@ static struct ibv_mr *__mthca_reg_mr(struct ibv_pd *pd, void *addr,
 	if (!mr)
 		return NULL;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
-	{
-		struct ibv_reg_mr_resp resp;
-
-		ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, mr,
-				     &cmd.ibv_cmd, sizeof cmd, &resp, sizeof resp);
-	}
-#else
-	ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, mr,
-			     &cmd.ibv_cmd, sizeof cmd);
-#endif
+	ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, mr, &cmd.ibv_cmd,
+			     sizeof cmd, &resp, sizeof resp);
 	if (ret) {
 		free(mr);
 		return NULL;
@@ -284,6 +276,7 @@ int mthca_resize_cq(struct ibv_cq *ibcq, int cqe)
 	struct mthca_resize_cq cmd;
 	struct ibv_mr *mr;
 	struct mthca_buf buf;
+	struct ibv_resize_cq_resp resp;
 	int old_cqe;
 	int ret;
 
@@ -317,15 +310,8 @@ int mthca_resize_cq(struct ibv_cq *ibcq, int cqe)
 	old_cqe = ibcq->cqe;
 
 	cmd.lkey = mr->lkey;
-#ifdef IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS
-	{
-		struct ibv_resize_cq_resp resp;
-		ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd,
-					&resp, sizeof resp);
-	}
-#else
-	ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd);
-#endif
+	ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd, &resp,
+				sizeof resp);
 	if (ret) {
 		mthca_dereg_mr(mr);
 		mthca_free_buf(&buf);
diff --git a/libnes/src/nes_uverbs.c b/libnes/src/nes_uverbs.c
index 7c2454e7f55a..141f769bf14b 100644
--- a/libnes/src/nes_uverbs.c
+++ b/libnes/src/nes_uverbs.c
@@ -172,23 +172,16 @@ struct ibv_mr *nes_ureg_mr(struct ibv_pd *pd, void *addr,
 {
 	struct ibv_mr *mr;
 	struct nes_ureg_mr cmd;
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	struct ibv_reg_mr_resp resp;
-#endif
 
 	mr = malloc(sizeof *mr);
 	if (!mr)
 		return NULL;
 
 	cmd.reg_type = NES_UMEMREG_TYPE_MEM;
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
 			access, mr, &cmd.ibv_cmd, sizeof cmd,
 			&resp, sizeof resp)) {
-#else
-	if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
-			access, mr, &cmd.ibv_cmd, sizeof cmd)) {
-#endif
 		free(mr);
 
 		return NULL;
@@ -225,9 +218,7 @@ int nes_ima_ureplace_cq(struct ibv_cq *cq,
 	struct nes_ucreate_cq_resp resp;
 	int comp_vector = nesucq->comp_vector;
 	struct nes_ureg_mr reg_mr_cmd;
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	struct ibv_reg_mr_resp reg_mr_resp;
-#endif
 	struct nes_uvcontext *nesvctx = to_nes_uctx(cq->context);
 
 	ret = ibv_cmd_destroy_cq(cq);
@@ -248,20 +239,12 @@ int nes_ima_ureplace_cq(struct ibv_cq *cq,
 
 	reg_mr_cmd.reg_type = NES_UMEMREG_TYPE_CQ;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	ret = ibv_cmd_reg_mr(&nesvctx->nesupd->ibv_pd, (void *)nesucq->cqes,
 			(nesucq->size*sizeof(struct nes_hw_cqe)),
 			(uintptr_t)nesucq->cqes,
 			IBV_ACCESS_LOCAL_WRITE, &nesucq->mr,
 			&reg_mr_cmd.ibv_cmd, sizeof reg_mr_cmd,
 			&reg_mr_resp, sizeof reg_mr_resp);
-#else
-	ret = ibv_cmd_reg_mr(&nesvctx->nesupd->ibv_pd, (void *)nesucq->cqes,
-			(nesucq->size*sizeof(struct nes_hw_cqe)),
-			(uintptr_t)nesucq->cqes,
-			IBV_ACCESS_LOCAL_WRITE, &nesucq->mr,
-			&reg_mr_cmd.ibv_cmd, sizeof reg_mr_cmd);
-#endif
 	if (ret) {
 		free((struct nes_hw_cqe *)nesucq->cqes);
 		goto err;
@@ -305,9 +288,7 @@ struct ibv_cq *nes_ucreate_cq(struct ibv_context *context, int cqe,
 {
 	struct nes_ucq *nesucq;
 	struct nes_ureg_mr reg_mr_cmd;
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	struct ibv_reg_mr_resp reg_mr_resp;
-#endif
 	struct nes_ucreate_cq cmd;
 	struct nes_ucreate_cq_resp resp;
 	int ret;
@@ -336,18 +317,11 @@ struct ibv_cq *nes_ucreate_cq(struct ibv_context *context, int cqe,
 	/* Register the memory for the CQ */
 	reg_mr_cmd.reg_type = NES_UMEMREG_TYPE_CQ;
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
 	ret = ibv_cmd_reg_mr(&nesvctx->nesupd->ibv_pd, (void *)nesucq->cqes,
 			(nesucq->size*sizeof(struct nes_hw_cqe)),
 			(uintptr_t)nesucq->cqes, IBV_ACCESS_LOCAL_WRITE, &nesucq->mr,
 			&reg_mr_cmd.ibv_cmd, sizeof reg_mr_cmd,
 			&reg_mr_resp, sizeof reg_mr_resp);
-#else
-	ret = ibv_cmd_reg_mr(&nesvctx->nesupd->ibv_pd, (void *)nesucq->cqes,
-			(nesucq->size*sizeof(struct nes_hw_cqe)),
-			(uintptr_t)nesucq->cqes, IBV_ACCESS_LOCAL_WRITE, &nesucq->mr,
-			&reg_mr_cmd.ibv_cmd, sizeof reg_mr_cmd);
-#endif
 	if (ret) {
 		/* fprintf(stderr, "ibv_cmd_reg_mr failed (ret = %d).\n", ret); */
 		free((struct nes_hw_cqe *)nesucq->cqes);
@@ -1039,9 +1013,7 @@ static int nes_vmapped_qp(struct nes_uqp *nesuqp, struct ibv_pd *pd, struct ibv_
 {
 	struct nes_ucreate_qp cmd;
 	struct nes_ureg_mr reg_mr_cmd;
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
         struct ibv_reg_mr_resp reg_mr_resp;
-#endif
 	int totalqpsize;
 	int ret;
 
@@ -1060,17 +1032,10 @@ static int nes_vmapped_qp(struct nes_uqp *nesuqp, struct ibv_pd *pd, struct ibv_
 	//fprintf(stderr, PFX "qp_rq_vbase = %p qp_sq_vbase=%p reg_mr = %p\n",
 	//		nesuqp->rq_vbase, nesuqp->sq_vbase, &nesuqp->mr);
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
         ret = ibv_cmd_reg_mr(pd, (void *)nesuqp->sq_vbase,totalqpsize,
 			     (uintptr_t) nesuqp->sq_vbase, IBV_ACCESS_LOCAL_WRITE,
 			     &nesuqp->mr, &reg_mr_cmd.ibv_cmd, sizeof reg_mr_cmd,
 			     &reg_mr_resp, sizeof reg_mr_resp);
-#else
-        ret = ibv_cmd_reg_mr(pd, (void *)nesuqp->sq_vbase,totalqpsize,
-			     (uintptr_t) nesuqp->sq_vbase, IBV_ACCESS_LOCAL_WRITE,
-			     &nesuqp->mr, &reg_mr_cmd.ibv_cmd, sizeof reg_mr_cmd);
-#endif
-
         if (ret) {
                 // fprintf(stderr, PFX "%s ibv_cmd_reg_mr failed (ret = %d).\n", __FUNCTION__, ret);
 		free((void *) nesuqp->sq_vbase);
diff --git a/librxe/src/rxe.c b/librxe/src/rxe.c
index ef7434e1d506..8f8cc91052e5 100644
--- a/librxe/src/rxe.c
+++ b/librxe/src/rxe.c
@@ -127,6 +127,7 @@ static struct ibv_mr *rxe_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
 {
 	struct ibv_mr *mr;
 	struct ibv_reg_mr cmd;
+	struct ibv_reg_mr_resp resp;
 	int ret;
 
 	mr = malloc(sizeof *mr);
@@ -134,19 +135,8 @@ static struct ibv_mr *rxe_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
 		return NULL;
 	}
 
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
-	{
-		struct ibv_reg_mr_resp resp;
-
-		ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
-				     access, mr, &cmd, sizeof cmd,
-				     &resp, sizeof resp);
-	}
-#else
-	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
-			     access, mr, &cmd, sizeof cmd);
-#endif
-
+	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr,
+			     &cmd, sizeof cmd, &resp, sizeof resp);
 	if (ret) {
 		free(mr);
 		return NULL;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 5/9] Remove HAVE_SYMVER_SUPPORT
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Doug Ledford, Yishai Hadas
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

cmake now hard requires GNU style symbol version support in the
assembler and linker.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 buildlib/config.h.in     |  3 ---
 libibverbs/src/ibverbs.h | 11 ++---------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/buildlib/config.h.in b/buildlib/config.h.in
index 3b94ea3e4f51..99103b779baf 100644
--- a/buildlib/config.h.in
+++ b/buildlib/config.h.in
@@ -9,9 +9,6 @@
 // FIXME: Remove this, we provide the netlink kernel headers ibacm needs
 #define HAVE_NETLINK 1
 
-// FIXME: Remove this, The cmake version hard-requires symbol version support
-#define HAVE_SYMVER_SUPPORT 1
-
 // FIXME: Remove this, The cmake version hard-requires new style CLOEXEC support
 #define STREAM_CLOEXEC "e"
 
diff --git a/libibverbs/src/ibverbs.h b/libibverbs/src/ibverbs.h
index 7892af4ad247..a01dff2b4638 100644
--- a/libibverbs/src/ibverbs.h
+++ b/libibverbs/src/ibverbs.h
@@ -47,16 +47,9 @@
 
 #define DEFAULT_ABI	"IBVERBS_1.1"
 
-#ifdef HAVE_SYMVER_SUPPORT
-#  define symver(name, api, ver) \
-	asm(".symver " #name "," #api "@" #ver)
-#  define default_symver(name, api) \
+#define symver(name, api, ver) asm(".symver " #name "," #api "@" #ver)
+#define default_symver(name, api)                                              \
 	asm(".symver " #name "," #api "@@" DEFAULT_ABI)
-#else
-#  define symver(name, api, ver)
-#  define default_symver(name, api) \
-	extern __typeof(name) api __attribute__((alias(#name)))
-#endif /* HAVE_SYMVER_SUPPORT */
 
 #define PFX		"libibverbs: "
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 6/9] Remove old compat definitions of wmb/rmb/etc
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Yishai Hadas, Vladimir Sokolovsky
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

The canonical place for these is infiniband/arch.h, nothing else
should declare them.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 libmlx4/src/mlx4.h   | 24 ------------------------
 libmlx5/src/mlx5.h   | 22 ----------------------
 libmthca/src/mthca.h |  8 --------
 3 files changed, 54 deletions(-)

diff --git a/libmlx4/src/mlx4.h b/libmlx4/src/mlx4.h
index 4551141d2007..1855cfbcbe48 100644
--- a/libmlx4/src/mlx4.h
+++ b/libmlx4/src/mlx4.h
@@ -49,30 +49,6 @@
 
 #include <valgrind/memcheck.h>
 
-#ifndef rmb
-#  define rmb() mb()
-#endif
-
-#ifndef wmb
-#  define wmb() mb()
-#endif
-
-#ifndef wc_wmb
-
-#if defined(__i386__)
-#define wc_wmb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory")
-#elif defined(__x86_64__)
-#define wc_wmb() asm volatile("sfence" ::: "memory")
-#elif defined(__ia64__)
-#define wc_wmb() asm volatile("fwb" ::: "memory")
-#elif defined(__s390x__)
-#define wc_wmb { asm volatile("" : : : "memory") }
-#else
-#define wc_wmb() wmb()
-#endif
-
-#endif
-
 #define HIDDEN		__attribute__((visibility ("hidden")))
 
 #define PFX		"mlx4: "
diff --git a/libmlx5/src/mlx5.h b/libmlx5/src/mlx5.h
index aa8b6feceb4e..c209a7964768 100644
--- a/libmlx5/src/mlx5.h
+++ b/libmlx5/src/mlx5.h
@@ -54,28 +54,6 @@
 
 #include <valgrind/memcheck.h>
 
-#ifndef rmb
-#  define rmb() mb()
-#endif
-
-#ifndef wmb
-#  define wmb() mb()
-#endif
-
-#ifndef wc_wmb
-
-#if defined(__i386__)
-#define wc_wmb() asm volatile("lock; addl $0, 0(%%esp) " ::: "memory")
-#elif defined(__x86_64__)
-#define wc_wmb() asm volatile("sfence" ::: "memory")
-#elif defined(__ia64__)
-#define wc_wmb() asm volatile("fwb" ::: "memory")
-#else
-#define wc_wmb() wmb()
-#endif
-
-#endif
-
 #define HIDDEN		__attribute__((visibility("hidden")))
 
 #ifdef HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE
diff --git a/libmthca/src/mthca.h b/libmthca/src/mthca.h
index 18d52291343f..da53010cec69 100644
--- a/libmthca/src/mthca.h
+++ b/libmthca/src/mthca.h
@@ -41,14 +41,6 @@
 
 #include <valgrind/memcheck.h>
 
-#ifndef rmb
-#  define rmb() mb()
-#endif
-
-#ifndef wmb
-#  define wmb() mb()
-#endif
-
 #define HIDDEN		__attribute__((visibility ("hidden")))
 
 #define PFX		"mthca: "
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 7/9] Remove old MADV_DONTFORK/DOFORK compat
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Doug Ledford, Yishai Hadas
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

All supported distros have this now.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 libibverbs/src/memory.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/libibverbs/src/memory.c b/libibverbs/src/memory.c
index 8e728c4f61fc..5c8255d47c15 100644
--- a/libibverbs/src/memory.c
+++ b/libibverbs/src/memory.c
@@ -46,17 +46,6 @@
 
 #include "ibverbs.h"
 
-/*
- * Most distro's headers don't have these yet.
- */
-#ifndef MADV_DONTFORK
-#define MADV_DONTFORK	10
-#endif
-
-#ifndef MADV_DOFORK
-#define MADV_DOFORK	11
-#endif
-
 struct ibv_mem_node {
 	enum {
 		IBV_RED,
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 8/9] Remove most checks of __BYTE_ORDER
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Steve Wise, Tatyana Nikolova, Hal Rosenstock, Doug Ledford,
	Yishai Hadas, Devesh Sharma, Sean Hefty, Bart Van Assche
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

For a long time now endian.h has defined sane fixed with conversion
macros, so lets just use them instead of rolling our own.

Also, htonll is defined in this source tree under infiniband/arch.h,
so all users of that macro can just use the header.

Someday we should also get rid of all the endless wrappers..

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 ibacm/linux/osd.h                    |  8 +-------
 libcxgb3/src/cxio_wr.h               | 10 +++-------
 libcxgb4/src/t4.h                    | 11 ++++-------
 libi40iw/src/i40iw_umain.h           | 18 ++----------------
 libibumad/src/sysfs.c                |  8 +-------
 libibverbs/include/infiniband/arch.h | 15 ++++++---------
 libnes/src/nes_umain.h               | 17 ++---------------
 libocrdma/src/ocrdma_verbs.c         | 32 ++++----------------------------
 librdmacm/examples/common.h          | 11 +++--------
 librdmacm/src/cma.h                  |  9 +--------
 srp_daemon/srp_daemon/srp_daemon.h   | 17 +----------------
 11 files changed, 28 insertions(+), 128 deletions(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 2c4db81b9e8e..c1e7d996c371 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -46,6 +46,7 @@
 #include <arpa/inet.h>
 #include <sys/time.h>
 #include <netinet/in.h>
+#include <infiniband/arch.h>
 
 #include <ccan/minmax.h>
 
@@ -55,13 +56,6 @@
 #define LIB_DESTRUCTOR __attribute__((destructor))
 #define CDECL_FUNC
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define htonll(x) bswap_64(x)
-#else
-#define htonll(x) (x)
-#endif
-#define ntohll(x) htonll(x)
-
 #if DEFINE_ATOMICS
 typedef struct { pthread_mutex_t mut; int val; } atomic_t;
 static inline int atomic_inc(atomic_t *atomic)
diff --git a/libcxgb3/src/cxio_wr.h b/libcxgb3/src/cxio_wr.h
index ece06bd0568c..e24c7fed7d76 100644
--- a/libcxgb3/src/cxio_wr.h
+++ b/libcxgb3/src/cxio_wr.h
@@ -50,13 +50,9 @@
 #define Q_COUNT(rptr,wptr) ((wptr)-(rptr))
 #define Q_PTR2IDX(ptr,size_log2) (ptr & ((1UL<<size_log2)-1))
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#  define cpu_to_pci32(val) ((val))
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#  define cpu_to_pci32(val) (__bswap_32((val)))
-#else
-#  error __BYTE_ORDER not defined
-#endif
+/* Generally speaking, PCI systems auto-byteswap on PCI accesses, so this is
+   probably wrong */
+#define cpu_to_pci32(val) htole32(val)
 
 #define RING_DOORBELL(doorbell, QPID) { \
 	*doorbell = cpu_to_pci32(QPID); \
diff --git a/libcxgb4/src/t4.h b/libcxgb4/src/t4.h
index e8c5cf66cb14..e519cc4087e6 100644
--- a/libcxgb4/src/t4.h
+++ b/libcxgb4/src/t4.h
@@ -62,13 +62,10 @@
 #define unlikely
 #define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#  define cpu_to_pci32(val) ((val))
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#  define cpu_to_pci32(val) (__bswap_32((val)))
-#else
-#  error __BYTE_ORDER not defined
-#endif
+
+/* Generally speaking, PCI systems auto-byteswap on PCI accesses, so this is
+   probably wrong */
+#define cpu_to_pci32(val) htole32(val)
 
 #define writel(v, a) do { *((volatile u32 *)(a)) = cpu_to_pci32(v); } while (0)
 
diff --git a/libi40iw/src/i40iw_umain.h b/libi40iw/src/i40iw_umain.h
index 39b54ba29dcb..13d3da89eba9 100644
--- a/libi40iw/src/i40iw_umain.h
+++ b/libi40iw/src/i40iw_umain.h
@@ -195,28 +195,14 @@ int i40iw_uattach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t);
 int i40iw_udetach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t);
 void i40iw_async_event(struct ibv_async_event *event);
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
 static inline uint32_t cpu_to_le32(uint32_t x)
 {
-	return x;
+	return htole32(x);
 }
 
 static inline uint32_t le32_to_cpu(uint32_t x)
 {
-	return x;
+	return le32toh(x);
 }
-#else
-static inline uint32_t cpu_to_le32(uint32_t x)
-{
-	return ((x & 0xFF000000) >> 24) | ((x & 0x00FF0000) >> 8) |
-	    ((x & 0x0000FF00) << 8) | ((x & 0x000000FF) << 24);
-}
-
-static inline uint32_t le32_to_cpu(uint32_t x)
-{
-	return ((x & 0xFF000000) >> 24) | ((x & 0x00FF0000) >> 8) |
-	    ((x & 0x0000FF00) << 8) | ((x & 0x000000FF) << 24);
-}
-#endif
 
 #endif /* i40iw_umain_H */
diff --git a/libibumad/src/sysfs.c b/libibumad/src/sysfs.c
index d10f312285ea..011e411f0951 100644
--- a/libibumad/src/sysfs.c
+++ b/libibumad/src/sysfs.c
@@ -41,15 +41,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <endian.h>
 #include <byteswap.h>
 #include <netinet/in.h>
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define htonll(x) bswap_64(x)
-#else
-#define htonll(x) (x)
-#endif
+#include <infiniband/arch.h>
 
 static int ret_code(void)
 {
diff --git a/libibverbs/include/infiniband/arch.h b/libibverbs/include/infiniband/arch.h
index e35ecf05bceb..bf0feec08d73 100644
--- a/libibverbs/include/infiniband/arch.h
+++ b/libibverbs/include/infiniband/arch.h
@@ -37,15 +37,12 @@
 #include <endian.h>
 #include <byteswap.h>
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t htonll(uint64_t x) { return bswap_64(x); }
-static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); }
-#elif __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t htonll(uint64_t x) { return x; }
-static inline uint64_t ntohll(uint64_t x) { return x; }
-#else
-#error __BYTE_ORDER is neither __LITTLE_ENDIAN nor __BIG_ENDIAN
-#endif
+#undef htonll
+#undef ntohll
+static inline uint64_t htonll(uint64_t x) { return htobe64(x); }
+static inline uint64_t ntohll(uint64_t x) { return be64toh(x); }
+#define htonll htonll
+#define ntohll ntohll
 
 /*
  * Architecture-specific defines.  Currently, an architecture is
diff --git a/libnes/src/nes_umain.h b/libnes/src/nes_umain.h
index c53acd7e90fe..91299823e675 100644
--- a/libnes/src/nes_umain.h
+++ b/libnes/src/nes_umain.h
@@ -393,26 +393,13 @@ int nes_uattach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t);
 int nes_udetach_mcast(struct ibv_qp *, const union ibv_gid *, uint16_t);
 void nes_async_event(struct ibv_async_event *event);
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
 static inline uint32_t cpu_to_le32(uint32_t x)
 {
-	return x;
+	return htole32(x);
 }
 static inline uint32_t le32_to_cpu(uint32_t x)
 {
-	return x;
+	return le32toh(x);
 }
-#else
-static inline uint32_t cpu_to_le32(uint32_t x)
-{
-	return (((x&0xFF000000)>>24) | ((x&0x00FF0000)>>8) |
-			((x&0x0000FF00)<<8) | ((x&0x000000FF)<<24));
-}
-static inline uint32_t le32_to_cpu(uint32_t x)
-{
-	return (((x&0xFF000000)>>24) | ((x&0x00FF0000)>>8) |
-			((x&0x0000FF00)<<8) | ((x&0x000000FF)<<24));
-}
-#endif
 
 #endif				/* nes_umain_H */
diff --git a/libocrdma/src/ocrdma_verbs.c b/libocrdma/src/ocrdma_verbs.c
index 6d58cb219fe1..163bf23f8914 100644
--- a/libocrdma/src/ocrdma_verbs.c
+++ b/libocrdma/src/ocrdma_verbs.c
@@ -46,6 +46,7 @@
 #include <sys/mman.h>
 #include <netinet/in.h>
 #include <unistd.h>
+#include <endian.h>
 
 #include "ocrdma_main.h"
 #include "ocrdma_abi.h"
@@ -54,48 +55,23 @@
 static void ocrdma_ring_cq_db(struct ocrdma_cq *cq, uint32_t armed,
 			      int solicited, uint32_t num_cqe);
 
-static inline uint32_t ocrdma_swap_endianness(uint32_t val)
-{
-	return ((val & 0xFF000000) >> 24) | ((val & 0xFF) << 24) |
-	    ((val & 0xFF00) << 8) | ((val & 0xFF0000) >> 8);
-}
-
 static inline uint32_t ocrdma_cpu_to_le(uint32_t val)
 {
-#if __BYTE_ORDER == __BIG_ENDIAN
-	return ocrdma_swap_endianness(val);
-#else
-	return val;
-#endif
+	return htole32(val);
 }
 
 static inline uint32_t ocrdma_le_to_cpu(uint32_t val)
 {
-#if __BYTE_ORDER == __BIG_ENDIAN
-	return ocrdma_swap_endianness(val);
-#else
-	return val;
-#endif
-}
-
-static inline uint32_t ocrdma_cpu_to_be(uint32_t val)
-{
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-	return ocrdma_swap_endianness(val);
-#else
-	return val;
-#endif
+	return le32toh(val);
 }
 
 static inline void ocrdma_swap_cpu_to_le(void *dst, uint32_t len)
 {
-#if __BYTE_ORDER == __BIG_ENDIAN
 	int i = 0;
 	uint32_t *src_ptr = dst;
 	uint32_t *dst_ptr = dst;
 	for (; i < (len / 4); i++)
-		*dst_ptr++ = ocrdma_swap_endianness(*src_ptr++);
-#endif
+		*dst_ptr++ = le32toh(*src_ptr++);
 }
 
 /*
diff --git a/librdmacm/examples/common.h b/librdmacm/examples/common.h
index f7511f039697..ac2d160b0044 100644
--- a/librdmacm/examples/common.h
+++ b/librdmacm/examples/common.h
@@ -34,20 +34,15 @@
 
 #include <stdlib.h>
 #include <sys/types.h>
-#include <byteswap.h>
+#include <endian.h>
 #include <poll.h>
 
 #include <rdma/rdma_cma.h>
 #include <rdma/rsocket.h>
 #include <infiniband/ib.h>
 
-#if __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return x; }
-static inline uint32_t cpu_to_be32(uint32_t x) { return x; }
-#else
-static inline uint64_t cpu_to_be64(uint64_t x) { return bswap_64(x); }
-static inline uint32_t cpu_to_be32(uint32_t x) { return bswap_32(x); }
-#endif
+static inline uint64_t cpu_to_be64(uint64_t x) { return htobe64(x); }
+static inline uint32_t cpu_to_be32(uint32_t x) { return htobe32(x); }
 
 extern int use_rs;
 
diff --git a/librdmacm/src/cma.h b/librdmacm/src/cma.h
index 16a55a67af9e..c2f603d6f439 100644
--- a/librdmacm/src/cma.h
+++ b/librdmacm/src/cma.h
@@ -44,6 +44,7 @@
 
 #include <rdma/rdma_cma.h>
 #include <infiniband/ib.h>
+#include <infiniband/arch.h>
 
 #include <ccan/minmax.h>
 
@@ -51,14 +52,6 @@
 
 #define PFX "librdmacm: "
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t htonll(uint64_t x) { return bswap_64(x); }
-static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); }
-#else
-static inline uint64_t htonll(uint64_t x) { return x; }
-static inline uint64_t ntohll(uint64_t x) { return x; }
-#endif
-
 /*
  * Fast synchronization for low contention locking.
  */
diff --git a/srp_daemon/srp_daemon/srp_daemon.h b/srp_daemon/srp_daemon/srp_daemon.h
index d6a2d8a84728..5d42d51e6d1c 100644
--- a/srp_daemon/srp_daemon/srp_daemon.h
+++ b/srp_daemon/srp_daemon/srp_daemon.h
@@ -42,26 +42,11 @@
 #include <byteswap.h>
 #include <infiniband/verbs.h>
 #include <infiniband/umad.h>
+#include <infiniband/arch.h>
 
 #include "config.h"
 #include "srp_ib_types.h"
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#ifndef htonll
-#define htonll(x) bswap_64(x)
-#endif
-#ifndef ntohll
-#define ntohll(x) bswap_64(x)
-#endif
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#ifndef htonll
-#define htonll(x) (x)
-#endif
-#ifndef ntohll
-#define ntohll(x) (x)
-#endif
-#endif
-
 #ifdef __cplusplus
 template <bool b> struct vki_static_assert { int m_bitfield:(2*b-1); };
 #define STATIC_ASSERT(expr) \
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 9/9] nes: Remove code guarded by HAVE_DECL_IBV_QPT_RAW_ETH
From: Jason Gunthorpe @ 2016-09-29 20:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Tatyana Nikolova
In-Reply-To: <1475182076-5411-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

Unclear what this was ever for, but we don't support it.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 libnes/src/nes_uverbs.c | 322 ------------------------------------------------
 1 file changed, 322 deletions(-)

diff --git a/libnes/src/nes_uverbs.c b/libnes/src/nes_uverbs.c
index 141f769bf14b..aa9c2b9e2b8c 100644
--- a/libnes/src/nes_uverbs.c
+++ b/libnes/src/nes_uverbs.c
@@ -206,80 +206,6 @@ int nes_udereg_mr(struct ibv_mr *mr)
 	return 0;
 }
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-static
-int nes_ima_ureplace_cq(struct ibv_cq *cq,
-			int mcrqf,
-			struct nes_uqp *nesuqp)
-{
-	struct nes_ucq *nesucq = to_nes_ucq(cq);
-	int ret;
-	struct nes_ucreate_cq cmd;
-	struct nes_ucreate_cq_resp resp;
-	int comp_vector = nesucq->comp_vector;
-	struct nes_ureg_mr reg_mr_cmd;
-	struct ibv_reg_mr_resp reg_mr_resp;
-	struct nes_uvcontext *nesvctx = to_nes_uctx(cq->context);
-
-	ret = ibv_cmd_destroy_cq(cq);
-	nes_debug(NES_DBG_UD, "%s(%d) mcrqf=%d ret=%d\n",
-			__func__,
-			__LINE__,
-			mcrqf,
-			ret);
-	if (ret)
-		return ret;
-
-	ret = ibv_cmd_dereg_mr(&nesucq->mr);
-	if (ret) {
-		fprintf(stderr, PFX "%s: Failed to deregister"
-			" CQ Memory Region.\n", __func__);
-		return ret;
-	}
-
-	reg_mr_cmd.reg_type = NES_UMEMREG_TYPE_CQ;
-
-	ret = ibv_cmd_reg_mr(&nesvctx->nesupd->ibv_pd, (void *)nesucq->cqes,
-			(nesucq->size*sizeof(struct nes_hw_cqe)),
-			(uintptr_t)nesucq->cqes,
-			IBV_ACCESS_LOCAL_WRITE, &nesucq->mr,
-			&reg_mr_cmd.ibv_cmd, sizeof reg_mr_cmd,
-			&reg_mr_resp, sizeof reg_mr_resp);
-	if (ret) {
-		free((struct nes_hw_cqe *)nesucq->cqes);
-		goto err;
-	}
-
-
-	/* Create the CQ */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.user_cq_buffer = (__u64)((uintptr_t)nesucq->cqes);
-	cmd.mcrqf = mcrqf | 0x20000000;    /* IMA specific sq number */
-
-	nes_debug(NES_DBG_UD, "%s(%d) mcrqf=%d\n",
-			__func__, __LINE__,
-			mcrqf);
-	ret = ibv_cmd_create_cq(cq->context,
-			nesucq->size-1,
-			cq->channel,
-			comp_vector,
-			&nesucq->ibv_cq, &cmd.ibv_cmd, sizeof cmd,
-			&resp.ibv_resp, sizeof resp);
-	if (ret)
-		goto err;
-
-	nesucq->cq_id = (uint16_t)resp.cq_id;
-	nesucq->udqp = nesuqp;
-	nes_debug(NES_DBG_UD, "%s(%d) cqid=%d mcrqf=%d\n",
-			__func__, __LINE__,
-			nesucq->cq_id, mcrqf);
-
-	return 0;
- err:
-	return ret;
-}
-#endif
-
 /**
  * nes_ucreate_cq
  */
@@ -1103,15 +1029,6 @@ struct ibv_qp *nes_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
 
 	/* fprintf(stderr, PFX "%s\n", __FUNCTION__); */
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-	if (attr->qp_type == IBV_QPT_RAW_ETH) {
-		attr->cap.max_send_sge = NES_UD_MAX_SG_LIST_SZ;
-		attr->cap.max_recv_sge = NES_UD_MAX_SG_LIST_SZ;
-		nes_debug(NES_DBG_UD, "%s(%d) patching max_sge for UD\n",
-				__func__, __LINE__);
-	}
-#endif
-
 	/* Sanity check QP size before proceeding */
 	sqdepth = nes_qp_get_qdepth(attr->cap.max_send_wr, attr->cap.max_send_sge);
 	if (!sqdepth) {
@@ -1168,58 +1085,6 @@ struct ibv_qp *nes_ucreate_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
 	nesuqp->ibv_qp.qp_num = resp.qp_id;
 	nesuqp->rdma0_msg = 1;
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-	if (attr->qp_type == IBV_QPT_RAW_ETH) {
-		int i = 0;
-
-		nesuqp->nes_ud_sksq_fd = open("/dev/infiniband/nes_ud_sksq",
-						O_RDWR);
-		if (nesuqp->nes_ud_sksq_fd <= 0)
-			return 0;
-		nesuqp->sksq_shared_ctxt = mmap(NULL, 4096,
-					PROT_WRITE | PROT_READ,
-					MAP_SHARED,
-					nesuqp->nes_ud_sksq_fd, 0);
-		if (nesuqp->sksq_shared_ctxt == 0)
-			return 0;
-
-		/* no LSMM for UD */
-		nesuqp->sq_head = 0;
-		nesuqp->sq_tail = 0;
-		nes_debug(NES_DBG_UD, "%s(%d) qpid=0x%x\n",
-			__func__, __LINE__, nesuqp->qp_id);
-
-		/* reallocate CQs after QP is created */
-		if (nes_ima_ureplace_cq(attr->recv_cq,
-					resp.qp_id & 0xffff,
-					nesuqp) != 0)
-			return NULL;
-
-		if (nes_ima_ureplace_cq(attr->send_cq,
-					resp.qp_id >> 16,
-					nesuqp) != 0)
-			return NULL;
-
-		/* allocate N+1, last one would be used for NULL */
-		nesuqp->pend_rx_wr = malloc(NES_UD_RX_BATCH_SZ *
-						sizeof *nesuqp->pend_rx_wr);
-		if (!nesuqp)
-			exit(0);
-
-		for (i = 0; i < NES_UD_RX_BATCH_SZ; i++) {
-			nesuqp->pend_rx_wr[i].sg_list =
-				malloc(NES_UD_MAX_SG_LIST_SZ *
-					sizeof *nesuqp->pend_rx_wr[i].sg_list);
-			nesuqp->pend_rx_wr[i].next =
-					(i < NES_UD_RX_BATCH_SZ-1) ?
-						&nesuqp->pend_rx_wr[i+1] : 0;
-		}
-		/* prepare the wr_id tables */
-		memset(&nesuqp->send_wr_id[0], 0, sizeof(uint64_t) * 512);
-		memset(&nesuqp->recv_wr_id[0], 0, sizeof(uint64_t) * 512);
-	}
-#endif
-
 	return &nesuqp->ibv_qp;
 }
 
@@ -1311,27 +1176,6 @@ int nes_udestroy_qp(struct ibv_qp *qp)
 
 	pthread_spin_destroy(&nesuqp->lock);
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-	if (qp->qp_type == IBV_QPT_RAW_ETH) {
-		int i = 0;
-
-		if (nesuqp->pend_rx_wr) {
-			for (i = 0; i < NES_UD_RX_BATCH_SZ; i++)
-				if (nesuqp->pend_rx_wr[i].sg_list) {
-					free(nesuqp->pend_rx_wr[i].sg_list);
-					nesuqp->pend_rx_wr[i].sg_list  = 0;
-				}
-		}
-		free(nesuqp->pend_rx_wr);
-		nesuqp->pend_rx_wr = 0;
-		if (nesuqp->sksq_shared_ctxt)
-			munmap(nesuqp->sksq_shared_ctxt, 4096);
-
-		nesuqp->sksq_shared_ctxt = 0;
-		close(nesuqp->nes_ud_sksq_fd);
-	}
-#endif
-
 	/* Clean any pending completions from the cq(s) */
 	if (nesuqp->send_cq)
 		nes_clean_cq(nesuqp, nesuqp->send_cq);
@@ -1343,85 +1187,6 @@ int nes_udestroy_qp(struct ibv_qp *qp)
 	return 0;
 }
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-static inline
-int nes_ima_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr,
-		struct ibv_send_wr **bad_wr)
-{
-	struct nes_uqp *nesuqp = to_nes_uqp(ib_qp);
-	int new_req_cnt = 0;
-	uint32_t outstanding_wqes;
-	uint32_t qsize = nesuqp->sq_size;
-	int ret = 0;
-	struct ibv_send_wr *tmp_wr = ib_wr;
-	struct nes_ud_send_wr *nes_ud_wr = 0;
-	int bc = 0;
-	int sq_head;
-	int wr_id_head;
-
-	while (tmp_wr) {
-		new_req_cnt++;
-		tmp_wr = tmp_wr->next;
-	}
-	if (nesuqp->sq_head >= nesuqp->sq_tail)
-		outstanding_wqes = nesuqp->sq_head - nesuqp->sq_tail;
-	else
-		outstanding_wqes = nesuqp->sq_head + qsize - nesuqp->sq_tail;
-
-	if (unlikely(outstanding_wqes >= (qsize - new_req_cnt)))
-		return -EINVAL;
-
-	/* we know that there is sufficient space in the send queue */
-	/* so we can store wr_id in the wr_id queue */
-	sq_head = nesuqp->sq_head;
-
-	if (sq_head + new_req_cnt >= qsize)
-		nesuqp->sq_head = sq_head + new_req_cnt - qsize;
-	else
-		nesuqp->sq_head = sq_head + new_req_cnt;
-
-	nes_ud_wr = (struct nes_ud_send_wr *)nesuqp->sksq_shared_ctxt;
-	bc = 0;
-
-	/* set up the qp id in the shared page message */
-	nes_ud_wr->qpn = nesuqp->qp_id;
-
-	while (ib_wr) {
-		nes_ud_wr->sg_list[bc].addr = ib_wr->sg_list[0].addr;
-		nes_ud_wr->sg_list[bc].length = ib_wr->sg_list[0].length;
-		nes_ud_wr->sg_list[bc].lkey = ib_wr->sg_list[0].lkey;
-		nes_ud_wr->flags = ib_wr->send_flags;
-		nes_ud_wr->flags = nes_ud_wr->flags | (ib_wr->imm_data << 16);
-		/* store the wr_id in the internal queue */
-		/* the queue is in sync with the queue in kernel */
-		/* the wr_id will be read in poll_cq */
-		wr_id_head = bc + sq_head;
-		if (wr_id_head > (qsize - 1))
-			wr_id_head = wr_id_head - qsize;
-
-		nesuqp->send_wr_id[wr_id_head] = ib_wr->wr_id;
-		if (++bc >= 64) {
-			nes_ud_wr->wr_cnt = bc;
-			ret = write(nesuqp->nes_ud_sksq_fd, 0, 0);
-			if (ret != 0)
-				goto out;
-			nes_ud_wr =
-			(struct nes_ud_send_wr *)nesuqp->sksq_shared_ctxt;
-			bc = 0;
-		}
-		ib_wr = ib_wr->next;
-	}
-	if (bc > 0) {
-		nes_ud_wr->wr_cnt = bc;
-		ret = write(nesuqp->nes_ud_sksq_fd, 0, 0);
-		if (ret != 0)
-			goto out;
-	}
-out:
-	return ret;
-}
-#endif
-
 /**
  * nes_upost_send
  */
@@ -1441,11 +1206,6 @@ int nes_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr,
 	uint32_t total_payload_length = 0;
 	int sge_index;
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-	if (ib_qp->qp_type == IBV_QPT_RAW_ETH)
-		return nes_ima_upost_send(ib_qp, ib_wr, bad_wr);
-#endif
-
 	pthread_spin_lock(&nesuqp->lock);
 
 	head = nesuqp->sq_head;
@@ -1617,83 +1377,6 @@ int nes_upost_send(struct ibv_qp *ib_qp, struct ibv_send_wr *ib_wr,
 	return err;
 }
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-static inline
-int nes_ima_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr,
-		struct ibv_recv_wr **bad_wr)
-{
-	struct nes_uqp *nesuqp = to_nes_uqp(ib_qp);
-	int new_req_cnt = 0;
-	uint32_t outstanding_wqes;
-	uint32_t qsize = nesuqp->rq_size;
-	struct ibv_send_wr *tmp_wr = (struct ibv_send_wr *)ib_wr;
-	int ret = 0;
-	struct nes_ud_recv_wr *nes_ud_wr;
-	int rq_head;
-	int bc;
-	int wr_id_head;
-
-	nes_ud_wr = (struct nes_ud_recv_wr *)
-				(((char *)nesuqp->sksq_shared_ctxt) + 2048);
-	while (tmp_wr) {
-		new_req_cnt++;
-		tmp_wr = tmp_wr->next;
-	}
-
-	if (nesuqp->rq_head >= nesuqp->rq_tail)
-		outstanding_wqes = nesuqp->rq_head - nesuqp->rq_tail;
-	else
-		outstanding_wqes = nesuqp->rq_head + qsize - nesuqp->rq_tail;
-
-	if (unlikely(outstanding_wqes >= (qsize - new_req_cnt)))
-		return -EINVAL;
-
-	/* now we know thay the rq has sufficient
-	   place so we can start wr_id storing */
-	rq_head = nesuqp->rq_head;
-
-	if (rq_head + new_req_cnt >= qsize)
-		nesuqp->rq_head = rq_head + new_req_cnt - qsize;
-	else
-		nesuqp->rq_head = rq_head + new_req_cnt;
-
-	/* set the queue number in the shared page */
-	nes_ud_wr->qpn = nesuqp->qp_id;
-	bc = 0;
-	while (ib_wr) {
-		if (ib_wr->num_sge > NES_UD_MAX_SG_LIST_SZ)
-			return -EINVAL;
-
-		nes_ud_wr->sg_list[nesuqp->pending_rcvs].addr =
-						ib_wr->sg_list[0].addr;
-		nes_ud_wr->sg_list[nesuqp->pending_rcvs].length =
-						ib_wr->sg_list[0].length;
-		nes_ud_wr->sg_list[nesuqp->pending_rcvs].lkey =
-						ib_wr->sg_list[0].lkey;
-
-		/* store the wr_id */
-		wr_id_head = bc + rq_head;
-		if (wr_id_head > (qsize - 1))
-			wr_id_head = wr_id_head - qsize;
-
-		nesuqp->recv_wr_id[wr_id_head] = ib_wr->wr_id;
-		bc++;
-
-		++nesuqp->pending_rcvs;
-		if (nesuqp->pending_rcvs >= NES_UD_RX_BATCH_SZ) {
-			nes_ud_wr->wr_cnt = nesuqp->pending_rcvs;
-			ret = read(nesuqp->nes_ud_sksq_fd, 0, 0);
-			if (ret != 0)
-				goto out;
-			nesuqp->pending_rcvs = 0;
-		}
-		ib_wr = ib_wr->next;
-	}
-out:
-	return ret;
-}
-#endif
-
 /**
  * nes_upost_recv
  */
@@ -1713,11 +1396,6 @@ int nes_upost_recv(struct ibv_qp *ib_qp, struct ibv_recv_wr *ib_wr,
 	uint32_t total_payload_length;
 	int sge_index;
 
-#if HAVE_DECL_IBV_QPT_RAW_ETH
-	if (ib_qp->qp_type == IBV_QPT_RAW_ETH)
-		return nes_ima_upost_recv(ib_qp, ib_wr, bad_wr);
-#endif
-
 	if (unlikely(ib_wr->num_sge > 4)) {
 		*bad_wr = ib_wr;
 		return -EINVAL;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* Re: [PATCH 2/9] Remove HAVE_VALGRIND_MEMCHECK_H/INCLUDE_VALGRIND
From: Bart Van Assche @ 2016-09-29 21:01 UTC (permalink / raw)
  To: Jason Gunthorpe, linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: Sean Hefty, Hal Rosenstock, Doug Ledford, Yishai Hadas,
	Vladimir Sokolovsky
In-Reply-To: <1475182076-5411-3-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

On 09/29/2016 01:47 PM, Jason Gunthorpe wrote:
> The cmake build system guarantees that valgrind/memcheck.h is present.
> If the system does not have it, or valgrind is disabled, then it is
> replaced with a dummy header full of empty stubs.

Independent of this patch: Valgrind has a stable ABI so I propose to add 
a copy of the memcheck.h header file to the rdma-core source tree. Many 
other open source projects already do this.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: [PATCH 1/9] Remove HAVE_CONFIG_H
From: Steve Wise @ 2016-09-29 21:22 UTC (permalink / raw)
  To: 'Jason Gunthorpe', linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: 'Mike Marciniszyn', 'Dennis Dalessandro',
	'Tatyana Nikolova', 'Sean Hefty',
	'Hal Rosenstock', 'Doug Ledford',
	'Yishai Hadas', 'Vladimir Sokolovsky',
	'Devesh Sharma', 'Moni Shoua',
	'open list:HF1 USERSPACE PROVIDER (for hf1.ko)'
In-Reply-To: <1475182076-5411-2-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

> Subject: [PATCH 1/9] Remove HAVE_CONFIG_H
> 
> The cmake build system guarantees this header exists, we do not need
> the define or the test.
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> ---

<snip>

>  libcxgb3/src/cq.c                   | 4 +---
>  libcxgb3/src/iwch.c                 | 4 +---
>  libcxgb3/src/qp.c                   | 4 +---
>  libcxgb3/src/verbs.c                | 4 +---
>  libcxgb4/src/cq.c                   | 4 +---
>  libcxgb4/src/dev.c                  | 4 +---
>  libcxgb4/src/qp.c                   | 4 +---
>  libcxgb4/src/verbs.c                | 4 +---

For the above changes:

Acked-by: Steve Wise <swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: [PATCH 8/9] Remove most checks of __BYTE_ORDER
From: Steve Wise @ 2016-09-29 21:26 UTC (permalink / raw)
  To: 'Jason Gunthorpe', linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: 'Tatyana Nikolova', 'Hal Rosenstock',
	'Doug Ledford', 'Yishai Hadas',
	'Devesh Sharma', 'Sean Hefty',
	'Bart Van Assche'
In-Reply-To: <1475182076-5411-9-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

> For a long time now endian.h has defined sane fixed with conversion
> macros, so lets just use them instead of rolling our own.
> 
> Also, htonll is defined in this source tree under infiniband/arch.h,
> so all users of that macro can just use the header.
> 
> Someday we should also get rid of all the endless wrappers..
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> ---
>  ibacm/linux/osd.h                    |  8 +-------
>  libcxgb3/src/cxio_wr.h               | 10 +++-------
>  libcxgb4/src/t4.h                    | 11 ++++-------
>  libi40iw/src/i40iw_umain.h           | 18 ++----------------
>  libibumad/src/sysfs.c                |  8 +-------
>  libibverbs/include/infiniband/arch.h | 15 ++++++---------
>  libnes/src/nes_umain.h               | 17 ++---------------
>  libocrdma/src/ocrdma_verbs.c         | 32 ++++----------------------------
>  librdmacm/examples/common.h          | 11 +++--------
>  librdmacm/src/cma.h                  |  9 +--------
>  srp_daemon/srp_daemon/srp_daemon.h   | 17 +----------------
>  11 files changed, 28 insertions(+), 128 deletions(-)
> 

<snip>

> diff --git a/libcxgb3/src/cxio_wr.h b/libcxgb3/src/cxio_wr.h
> index ece06bd0568c..e24c7fed7d76 100644
> --- a/libcxgb3/src/cxio_wr.h
> +++ b/libcxgb3/src/cxio_wr.h
> @@ -50,13 +50,9 @@
>  #define Q_COUNT(rptr,wptr) ((wptr)-(rptr))
>  #define Q_PTR2IDX(ptr,size_log2) (ptr & ((1UL<<size_log2)-1))
> 
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> -#  define cpu_to_pci32(val) ((val))
> -#elif __BYTE_ORDER == __BIG_ENDIAN
> -#  define cpu_to_pci32(val) (__bswap_32((val)))
> -#else
> -#  error __BYTE_ORDER not defined
> -#endif
> +/* Generally speaking, PCI systems auto-byteswap on PCI accesses, so this is
> +   probably wrong */
> +#define cpu_to_pci32(val) htole32(val)
> 

If this was wrong, then nothing would work.  So I think you should remove the
comment.

>  #define RING_DOORBELL(doorbell, QPID) { \
>  	*doorbell = cpu_to_pci32(QPID); \

See RING_DOORBELL() is used in the .c files

> diff --git a/libcxgb4/src/t4.h b/libcxgb4/src/t4.h
> index e8c5cf66cb14..e519cc4087e6 100644
> --- a/libcxgb4/src/t4.h
> +++ b/libcxgb4/src/t4.h
> @@ -62,13 +62,10 @@
>  #define unlikely
>  #define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
>  #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> -#  define cpu_to_pci32(val) ((val))
> -#elif __BYTE_ORDER == __BIG_ENDIAN
> -#  define cpu_to_pci32(val) (__bswap_32((val)))
> -#else
> -#  error __BYTE_ORDER not defined
> -#endif
> +
> +/* Generally speaking, PCI systems auto-byteswap on PCI accesses, so this is
> +   probably wrong */
> +#define cpu_to_pci32(val) htole32(val)
> 

Ditto.

>  #define writel(v, a) do { *((volatile u32 *)(a)) = cpu_to_pci32(v); } while
(0)
>

Ditto.


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v2 4/7] blk-mq: Introduce blk_quiesce_queue() and blk_resume_queue()
From: Ming Lei @ 2016-09-29 21:51 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Jens Axboe, Christoph Hellwig, James Bottomley,
	Martin K. Petersen, Mike Snitzer, Doug Ledford, Keith Busch,
	linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
In-Reply-To: <a9eb4e95-6d77-e527-c42a-fd2e6f104bed-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>

On Thu, Sep 29, 2016 at 7:59 AM, Bart Van Assche
<bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org> wrote:
> blk_quiesce_queue() prevents that new queue_rq() invocations

blk_mq_quiesce_queue()

> occur and waits until ongoing invocations have finished. This
> function does *not* wait until all outstanding requests have

I guess it still may wait finally since this way may exhaust tag space
easily, :-)

> finished (this means invocation of request.end_io()).
> blk_resume_queue() resumes normal I/O processing.
>
> Signed-off-by: Bart Van Assche <bart.vanassche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
> Cc: Hannes Reinecke <hare-IBi9RG/b67k@public.gmane.org>
> Cc: Johannes Thumshirn <jthumshirn-l3A5Bk7waGM@public.gmane.org>
> ---
>  block/blk-mq.c         | 137 ++++++++++++++++++++++++++++++++++++++++++++-----
>  include/linux/blk-mq.h |   2 +
>  include/linux/blkdev.h |   5 ++
>  3 files changed, 131 insertions(+), 13 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index d8c45de..f5c71ad 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -58,15 +58,23 @@ static void blk_mq_hctx_clear_pending(struct blk_mq_hw_ctx *hctx,
>         sbitmap_clear_bit(&hctx->ctx_map, ctx->index_hw);
>  }
>
> -void blk_mq_freeze_queue_start(struct request_queue *q)
> +static bool __blk_mq_freeze_queue_start(struct request_queue *q,
> +                                       bool kill_percpu_ref)
>  {
>         int freeze_depth;
>
>         freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
>         if (freeze_depth == 1) {
> -               percpu_ref_kill(&q->q_usage_counter);
> +               if (kill_percpu_ref)
> +                       percpu_ref_kill(&q->q_usage_counter);
>                 blk_mq_run_hw_queues(q, false);
>         }
> +       return freeze_depth == 1;
> +}
> +
> +void blk_mq_freeze_queue_start(struct request_queue *q)
> +{
> +       __blk_mq_freeze_queue_start(q, true);
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_start);
>
> @@ -102,19 +110,90 @@ void blk_mq_freeze_queue(struct request_queue *q)
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_freeze_queue);
>
> -void blk_mq_unfreeze_queue(struct request_queue *q)
> +static bool __blk_mq_unfreeze_queue(struct request_queue *q,
> +                                   bool reinit_percpu_ref)
>  {
>         int freeze_depth;
>
>         freeze_depth = atomic_dec_return(&q->mq_freeze_depth);
>         WARN_ON_ONCE(freeze_depth < 0);
>         if (!freeze_depth) {
> -               percpu_ref_reinit(&q->q_usage_counter);
> +               if (reinit_percpu_ref)
> +                       percpu_ref_reinit(&q->q_usage_counter);
>                 wake_up_all(&q->mq_freeze_wq);
>         }
> +       return freeze_depth == 0;
> +}
> +
> +void blk_mq_unfreeze_queue(struct request_queue *q)
> +{
> +       __blk_mq_unfreeze_queue(q, true);
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
>
> +/**
> + * blk_mq_quiesce_queue() - wait until all pending queue_rq calls have finished
> + *
> + * Prevent that new I/O requests are queued and wait until all pending
> + * queue_rq() calls have finished. Must not be called if the queue has already
> + * been frozen. Additionally, freezing the queue after having quiesced the
> + * queue and before resuming the queue is not allowed.
> + *
> + * Note: this function does not prevent that the struct request end_io()
> + * callback function is invoked.
> + */
> +void blk_mq_quiesce_queue(struct request_queue *q)
> +{
> +       struct blk_mq_hw_ctx *hctx;
> +       unsigned int i;
> +       bool res, rcu = false;
> +
> +       spin_lock_irq(q->queue_lock);
> +       WARN_ON_ONCE(blk_queue_quiescing(q));
> +       queue_flag_set(QUEUE_FLAG_QUIESCING, q);
> +       spin_unlock_irq(q->queue_lock);
> +
> +       res = __blk_mq_freeze_queue_start(q, false);

Looks the implementation is a bit tricky and complicated, if the percpu
usage counter isn't killed, it isn't necessary to touch .mq_freeze_depth
since you use QUEUE_FLAG_QUIESCING to set/get this status of
the queue.

Then using synchronize_rcu() and rcu_read_lock()/rcu_read_unlock()
with the flag of QUIESCING may be enough to wait for completing
of ongoing invocations of .queue_rq() and avoid to run new .queue_rq,
right?

> +       WARN_ON_ONCE(!res);
> +       queue_for_each_hw_ctx(q, hctx, i) {
> +               if (hctx->flags & BLK_MQ_F_BLOCKING) {
> +                       mutex_lock(&hctx->queue_rq_mutex);
> +                       mutex_unlock(&hctx->queue_rq_mutex);

Could you explain a bit why all BLOCKING is treated so special? And
that flag just means the hw queue always need to schedule asynchronously,
and of couse even though the flag isn't set, it still may be run
asynchronously too. So looks it should be enough to just use RCU.

> +               } else {
> +                       rcu = true;
> +               }
> +       }
> +       if (rcu)
> +               synchronize_rcu();
> +
> +       spin_lock_irq(q->queue_lock);
> +       WARN_ON_ONCE(!blk_queue_quiescing(q));
> +       queue_flag_clear(QUEUE_FLAG_QUIESCING, q);
> +       spin_unlock_irq(q->queue_lock);
> +}
> +EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue);
> +
> +/**
> + * blk_mq_resume_queue() - resume request processing
> + *
> + * Resume blk_queue_enter() calls that have been suspended by
> + * blk_mq_quiesce_queue().
> + *
> + * The caller is responsible for serializing blk_mq_quiesce_queue() and
> + * blk_mq_resume_queue().
> + */
> +void blk_mq_resume_queue(struct request_queue *q)
> +{
> +       bool res;
> +
> +       res = __blk_mq_unfreeze_queue(q, false);
> +       WARN_ON_ONCE(!res);
> +       WARN_ON_ONCE(blk_queue_quiescing(q));
> +
> +       blk_mq_run_hw_queues(q, false);
> +}
> +EXPORT_SYMBOL_GPL(blk_mq_resume_queue);
> +
>  void blk_mq_wake_waiters(struct request_queue *q)
>  {
>         struct blk_mq_hw_ctx *hctx;
> @@ -488,6 +567,9 @@ static void blk_mq_requeue_work(struct work_struct *work)
>         struct request *rq, *next;
>         unsigned long flags;
>
> +       if (blk_queue_quiescing(q))
> +               return;
> +
>         spin_lock_irqsave(&q->requeue_lock, flags);
>         list_splice_init(&q->requeue_list, &rq_list);
>         spin_unlock_irqrestore(&q->requeue_lock, flags);
> @@ -782,7 +864,7 @@ static inline unsigned int queued_to_index(unsigned int queued)
>   * of IO. In particular, we'd like FIFO behaviour on handling existing
>   * items on the hctx->dispatch list. Ignore that for now.
>   */
> -static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
> +static void blk_mq_process_rq_list(struct blk_mq_hw_ctx *hctx)
>  {
>         struct request_queue *q = hctx->queue;
>         struct request *rq;
> @@ -791,9 +873,6 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
>         struct list_head *dptr;
>         int queued;
>
> -       if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state)))
> -               return;
> -
>         WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
>                 cpu_online(hctx->next_cpu));
>
> @@ -883,7 +962,24 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
>                  *
>                  * blk_mq_run_hw_queue() already checks the STOPPED bit
>                  **/
> -               blk_mq_run_hw_queue(hctx, true);
> +               if (!blk_queue_quiescing(q))
> +                       blk_mq_run_hw_queue(hctx, true);
> +       }
> +}
> +
> +static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
> +{
> +       if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state)))
> +               return;
> +
> +       if (hctx->flags & BLK_MQ_F_BLOCKING) {
> +               mutex_lock(&hctx->queue_rq_mutex);
> +               blk_mq_process_rq_list(hctx);
> +               mutex_unlock(&hctx->queue_rq_mutex);
> +       } else {
> +               rcu_read_lock();
> +               blk_mq_process_rq_list(hctx);
> +               rcu_read_unlock();
>         }
>  }
>
> @@ -1341,7 +1437,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
>                 blk_mq_bio_to_request(rq, bio);
>
>                 /*
> -                * We do limited pluging. If the bio can be merged, do that.
> +                * We do limited plugging. If the bio can be merged, do that.
>                  * Otherwise the existing request in the plug list will be
>                  * issued. So the plug list will have one request at most
>                  */
> @@ -1361,9 +1457,23 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
>                 blk_mq_put_ctx(data.ctx);
>                 if (!old_rq)
>                         goto done;
> -               if (!blk_mq_direct_issue_request(old_rq, &cookie))
> -                       goto done;
> -               blk_mq_insert_request(old_rq, false, true, true);
> +
> +               if (data.hctx->flags & BLK_MQ_F_BLOCKING) {
> +                       mutex_lock(&data.hctx->queue_rq_mutex);
> +                       if (blk_queue_quiescing(q) ||
> +                           blk_mq_direct_issue_request(old_rq, &cookie) != 0)
> +                               blk_mq_insert_request(old_rq, false, true,
> +                                                     true);
> +                       mutex_unlock(&data.hctx->queue_rq_mutex);
> +               } else {
> +                       rcu_read_lock();
> +                       if (blk_queue_quiescing(q) ||
> +                           blk_mq_direct_issue_request(old_rq, &cookie) != 0)
> +                               blk_mq_insert_request(old_rq, false, true,
> +                                                     true);
> +                       rcu_read_unlock();
> +               }
> +
>                 goto done;
>         }
>
> @@ -1702,6 +1812,7 @@ static int blk_mq_init_hctx(struct request_queue *q,
>         INIT_DELAYED_WORK(&hctx->delay_work, blk_mq_delay_work_fn);
>         spin_lock_init(&hctx->lock);
>         INIT_LIST_HEAD(&hctx->dispatch);
> +       mutex_init(&hctx->queue_rq_mutex);
>         hctx->queue = q;
>         hctx->queue_num = hctx_idx;
>         hctx->flags = set->flags & ~BLK_MQ_F_TAG_SHARED;
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index 368c460d..4b970f1 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -41,6 +41,8 @@ struct blk_mq_hw_ctx {
>
>         struct blk_mq_tags      *tags;
>
> +       struct mutex            queue_rq_mutex;
> +
>         unsigned long           queued;
>         unsigned long           run;
>  #define BLK_MQ_MAX_DISPATCH_ORDER      7
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index c47c358..d365cdf 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -505,6 +505,7 @@ struct request_queue {
>  #define QUEUE_FLAG_FUA        24       /* device supports FUA writes */
>  #define QUEUE_FLAG_FLUSH_NQ    25      /* flush not queueuable */
>  #define QUEUE_FLAG_DAX         26      /* device supports DAX */
> +#define QUEUE_FLAG_QUIESCING   27
>
>  #define QUEUE_FLAG_DEFAULT     ((1 << QUEUE_FLAG_IO_STAT) |            \
>                                  (1 << QUEUE_FLAG_STACKABLE)    |       \
> @@ -595,6 +596,8 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
>  #define blk_queue_secure_erase(q) \
>         (test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags))
>  #define blk_queue_dax(q)       test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags)
> +#define blk_queue_quiescing(q) test_bit(QUEUE_FLAG_QUIESCING,  \
> +                                        &(q)->queue_flags)
>
>  #define blk_noretry_request(rq) \
>         ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
> @@ -824,6 +827,8 @@ extern void __blk_run_queue(struct request_queue *q);
>  extern void __blk_run_queue_uncond(struct request_queue *q);
>  extern void blk_run_queue(struct request_queue *);
>  extern void blk_run_queue_async(struct request_queue *q);
> +extern void blk_mq_quiesce_queue(struct request_queue *q);
> +extern void blk_mq_resume_queue(struct request_queue *q);
>  extern int blk_rq_map_user(struct request_queue *, struct request *,
>                            struct rq_map_data *, void __user *, unsigned long,
>                            gfp_t);
> --
> 2.10.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-block" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH v3 0/9] SELinux support for Infiniband RDMA
From: Paul Moore @ 2016-09-29 22:16 UTC (permalink / raw)
  To: Daniel Jurgens
  Cc: Jason Gunthorpe, Leon Romanovsky,
	chrisw-69jw2NvuJkxg9hUCZPvPmw@public.gmane.org, Stephen Smalley,
	Eric Paris, dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	selinux-+05T5uksL2qpZYMLLGbcSA@public.gmane.org,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Yevgeny Petrilin
In-Reply-To: <VI1PR0501MB24299E036F1FCD335A2C2049C4C80-o1MPJYiShEyB6Z+oivrBG8DSnupUy6xnnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>

On Fri, Sep 23, 2016 at 9:26 AM, Daniel Jurgens <danielj-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:
> On 9/20/2016 6:43 PM, Paul Moore wrote:
>> On Tue, Sep 6, 2016 at 4:02 PM, Jason Gunthorpe
>> <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote:
>>> On Thu, Sep 01, 2016 at 02:06:46PM -0400, Paul Moore wrote:
>>>
>>>> Jason and/or Daniel, I think it would be helpful if you could explain
>>>> both the InifiniBand and IP based approaches for those of us who know
>>>> SELinux, but not necessarily the RDMA and InfiniBand portions of this
>>>> discussion.  Be verbose and explain it as if we were idiots (I get
>>>> called that enough, it must be true).
>>> Well, I'm not really familiar with SELinux, I know a little bit about
>>> how labels are applied in the netstack, but not that much...
>>>
>>> The RDMA subsystem supports 4 different networking standards, and they
>>> each have their own objects..
>> All right, I'm done traveling for a bit and it seems like this
>> discussion has settled into a stalemate so let's try to pick things
>> back up and sort this out.
>>
>> Starting we a better RDMA education for me.
>>
>> So far the discussion has been around providing access controls at the
>> transport layer, are there any RDMA entities that are transport
>> agnostic that might be better suited for what we are trying to do?  Or
>> is it simply that the RDMA layer is tied so tightly to the underlying
>> transport that we can't separate the two and have to consider them as
>> one?
>
> Welcome back Paul.
>
> I don't think there is a transport agnostic way to provide the kind of control I use in this patch set, which is very Infiniband specific.  RoCE uses VLANs and they are conceptually similar to subnet partitions, but the means of using them is completely different.  To use a different VLAN the user must select a GID for that VLAN.  One could provide a means to control RoCE access to VLANs by labeling GIDs and controlling them in a similar way to how I do PKeys.  That approach doesn't help with Infiniband partitions though, because the same GID can be used on multiple partitions.  It's also not very desirable from a policy writers perspective because it makes it so a bespoke policy is required per node.
>
> Regardless of any other approaches one might like to use to provide access control for RDMA non-Infiniband transport I think controlling access to Infiniband PKeys is still a desirable feature and I don't see any other way to have that.

Let me try to summarize and work through some of this stuff, please
correct me if any of this is wrong.

The queue pair (QP) concept lives in the RDMA layer and isn't tied to
any particular transport.  They appear to be somewhat analogous to
network sockets, although I'm guessing they can't be shared/passed
between process like a network socket, yes?

The IB partition is similar to a ethernet VLAN in that it providedes
enforced separation across the network; IB uses partition keys, VLANs
use tags/IDs.  IB partition keys are a 16 bit number, GIDs appear to
be a 16 byte number created from some combination of IP address, MAC
address, and VLAN ID.

In the case of RDMA over IB, we want to control QP access to
partitions/pkeys; in the case of RDMA over ethernet we want to control
QP access to VLANs/GIDs.

Is the above correct?

-- 
paul moore
www.paul-moore.com
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 8/9] Remove most checks of __BYTE_ORDER
From: Jason Gunthorpe @ 2016-09-29 22:28 UTC (permalink / raw)
  To: Steve Wise
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, 'Tatyana Nikolova',
	'Hal Rosenstock', 'Doug Ledford',
	'Yishai Hadas', 'Devesh Sharma',
	'Sean Hefty', 'Bart Van Assche'
In-Reply-To: <00e001d21a98$3265f6e0$9731e4a0$@opengridcomputing.com>

On Thu, Sep 29, 2016 at 04:26:52PM -0500, Steve Wise wrote:

> > +/* Generally speaking, PCI systems auto-byteswap on PCI accesses, so this is
> > +   probably wrong */
> > +#define cpu_to_pci32(val) htole32(val)
> 
> If this was wrong, then nothing would work.  So I think you should
> remove the comment.

I added the comment because cxgb* was the only provider that seemed to
be obviously byte swapping MMIO.

Since htole32 is a NOP on x86 and ARM64 the driver would work fine
with or without it. Do you know this driver works on big endian
powerpc? That would help answer the question for sure.

I looked at this some more, and I still don't really know what is the
right answer.

In the kernel the swapping behavior of 'writel' is architecture (and
sometimes even platform) specific. Looking at the kernel headers
suggests that BE PPC needs an explicit swap and BE ARM does not (eg
the hardware swaps). Maybe. There are a lot of layers of macros in
this area..

However, I can't find an obvious swap in mlx4, which I think is the
most widely tested provider. Does it work on BE PPC?

One of the things I'd like to see done is to consolidate the mmio
accessors.. The note was a reminder to try and figure out what is
actually right here.. Appreciate any help!

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox