Skip to contentSkip to conversation

add rxe (soft RoCE)

PATCH In review [email protected] 6 participants 85 messages Jul 24, 2011 – Sep 5, 2012 36 messages not in the archive Page 2 of 2

Subsystems (2)
lore
Share & tools
lore
#94 lore raw

PATCH v2 31/37 add rxe.c

In reply to [email protected]

module main for ib_rxe

---
 drivers/infiniband/hw/rxe/rxe.c |  549 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 549 insertions(+)
drivers/infiniband/hw/rxe/rxe.c new file +549 -0
Index: infiniband/drivers/infiniband/hw/rxe/rxe.c
===================================================================
@@ -0,0 +1,549 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *	- Redistributions of source code must retain the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer.
+ *
+ *	- Redistributions in binary form must reproduce the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer in the documentation and/or other materials
+ *	  provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "rxe.h"
+#include "rxe_loc.h"
+
+MODULE_AUTHOR("Bob Pearson, Frank Zago, John Groves");
+MODULE_DESCRIPTION("Soft RDMA transport");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static int rxe_max_ucontext = RXE_MAX_UCONTEXT;
+module_param_named(max_ucontext, rxe_max_ucontext, int, 0644);
+MODULE_PARM_DESC(max_ucontext, "max user contexts per device");
+
+static int rxe_max_qp = RXE_MAX_QP;
+module_param_named(max_qp, rxe_max_qp, int, 0444);
+MODULE_PARM_DESC(max_qp, "max QPs per device");
+
+static int rxe_max_qp_wr = RXE_MAX_QP_WR;
+module_param_named(max_qp_wr, rxe_max_qp_wr, int, 0644);
+MODULE_PARM_DESC(max_qp_wr, "max send or recv WR's per QP");
+
+static int rxe_max_inline_data = RXE_MAX_INLINE_DATA;
+module_param_named(max_inline_data, rxe_max_inline_data, int, 0644);
+MODULE_PARM_DESC(max_inline_data, "max inline data per WR");
+
+static int rxe_max_cq = RXE_MAX_CQ;
+module_param_named(max_cq, rxe_max_cq, int, 0644);
+MODULE_PARM_DESC(max_cq, "max CQs per device");
+
+static int rxe_max_mr = RXE_MAX_MR;
+module_param_named(max_mr, rxe_max_mr, int, 0644);
+MODULE_PARM_DESC(max_mr, "max MRs per device");
+
+static int rxe_max_fmr = RXE_MAX_FMR;
+module_param_named(max_fmr, rxe_max_fmr, int, 0644);
+MODULE_PARM_DESC(max_fmr, "max MRs per device");
+
+static int rxe_max_mw = RXE_MAX_MW;
+module_param_named(max_mw, rxe_max_mw, int, 0644);
+MODULE_PARM_DESC(max_mw, "max MWs per device");
+
+static int rxe_max_log_cqe = RXE_MAX_LOG_CQE;
+module_param_named(max_log_cqe, rxe_max_log_cqe, int, 0644);
+MODULE_PARM_DESC(max_log_cqe, "Log2 of max CQ entries per CQ");
+
+int rxe_fast_comp = 2;
+module_param_named(fast_comp, rxe_fast_comp, int, 0644);
+MODULE_PARM_DESC(fast_comp, "fast path call to completer "
+		 "(0=no, 1=no int context, 2=any context)");
+
+int rxe_fast_resp = 2;
+module_param_named(fast_resp, rxe_fast_resp, int, 0644);
+MODULE_PARM_DESC(fast_resp, "enable fast path call to responder "
+		 "(0=no, 1=no int context, 2=any context)");
+
+int rxe_fast_req = 2;
+module_param_named(fast_req, rxe_fast_req, int, 0644);
+MODULE_PARM_DESC(fast_req, "enable fast path call to requester "
+		 "(0=no, 1=no int context, 2=any context)");
+
+int rxe_fast_arb = 2;
+module_param_named(fast_arb, rxe_fast_arb, int, 0644);
+MODULE_PARM_DESC(fast_arb, "enable fast path call to arbiter "
+		 "(0=no, 1=no int context, 2=any context)");
+
+int rxe_crc_disable;
+EXPORT_SYMBOL(rxe_crc_disable);
+module_param_named(crc_disable, rxe_crc_disable, int, 0644);
+MODULE_PARM_DESC(rxe_crc_disable,
+		 "Disable crc32 computation on outbound packets");
+
+int rxe_nsec_per_packet = 200;
+module_param_named(nsec_per_packet, rxe_nsec_per_packet, int, 0644);
+MODULE_PARM_DESC(nsec_per_packet,
+		 "minimum output packet delay nsec");
+
+int rxe_nsec_per_kbyte = 700;
+module_param_named(nsec_per_kbyte, rxe_nsec_per_kbyte, int, 0644);
+MODULE_PARM_DESC(nsec_per_kbyte,
+		 "minimum output packet delay per kbyte nsec");
+
+int rxe_max_skb_per_qp = 800;
+module_param_named(max_skb_per_qp, rxe_max_skb_per_qp, int, 0644);
+MODULE_PARM_DESC(max_skb_per_qp,
+		 "maximum skb's posted for output");
+
+int rxe_max_req_comp_gap = 128;
+module_param_named(max_req_comp_gap, rxe_max_req_comp_gap, int, 0644);
+MODULE_PARM_DESC(max_req_comp_gap,
+		 "max difference between req.psn and comp.psn");
+
+int rxe_max_pkt_per_ack = 64;
+module_param_named(max_pkt_per_ack, rxe_max_pkt_per_ack, int, 0644);
+MODULE_PARM_DESC(max_pkt_per_ack,
+		 "max packets before an ack will be generated");
+
+int rxe_default_mtu = 1024;
+module_param_named(default_mtu, rxe_default_mtu, int, 0644);
+MODULE_PARM_DESC(default_mtu,
+		 "default rxe port mtu");
+
+/* free resources for all ports on a device */
+static void rxe_cleanup_ports(struct rxe_dev *rxe)
+{
+	unsigned int port_num;
+	struct rxe_port *port;
+
+	for (port_num = 1; port_num <= rxe->num_ports; port_num++) {
+		port = &rxe->port[port_num - 1];
+
+		kfree(port->guid_tbl);
+		port->guid_tbl = NULL;
+
+		kfree(port->pkey_tbl);
+		port->pkey_tbl = NULL;
+	}
+
+	kfree(rxe->port);
+	rxe->port = NULL;
+}
+
+/* free resources for a rxe device
+   all objects created for this device
+   must have been destroyed */
+static void rxe_cleanup(struct rxe_dev *rxe)
+{
+	rxe_cleanup_task(&rxe->arbiter.task);
+
+	rxe_pool_cleanup(&rxe->uc_pool);
+	rxe_pool_cleanup(&rxe->pd_pool);
+	rxe_pool_cleanup(&rxe->ah_pool);
+	rxe_pool_cleanup(&rxe->srq_pool);
+	rxe_pool_cleanup(&rxe->qp_pool);
+	rxe_pool_cleanup(&rxe->cq_pool);
+	rxe_pool_cleanup(&rxe->mr_pool);
+	rxe_pool_cleanup(&rxe->fmr_pool);
+	rxe_pool_cleanup(&rxe->mw_pool);
+	rxe_pool_cleanup(&rxe->mc_grp_pool);
+	rxe_pool_cleanup(&rxe->mc_elem_pool);
+
+	rxe_cleanup_ports(rxe);
+}
+
+/* called when all references have been dropped */
+void rxe_release(struct kref *kref)
+{
+	struct rxe_dev *rxe = container_of(kref, struct rxe_dev, ref_cnt);
+
+	rxe_cleanup(rxe);
+	ib_dealloc_device(&rxe->ib_dev);
+	module_put(THIS_MODULE);
+	rxe->ifc_ops->release(rxe);
+}
+
+/* initialize rxe device parameters */
+static int rxe_init_device_param(struct rxe_dev *rxe)
+{
+	rxe->num_ports				= RXE_NUM_PORT;
+	rxe->max_inline_data			= rxe_max_inline_data;
+
+	rxe->attr.fw_ver			= RXE_FW_VER;
+	rxe->attr.max_mr_size			= RXE_MAX_MR_SIZE;
+	rxe->attr.page_size_cap			= RXE_PAGE_SIZE_CAP;
+	rxe->attr.vendor_id			= RXE_VENDOR_ID;
+	rxe->attr.vendor_part_id		= RXE_VENDOR_PART_ID;
+	rxe->attr.hw_ver			= RXE_HW_VER;
+	rxe->attr.max_qp			= rxe_max_qp;
+	rxe->attr.max_qp_wr			= rxe_max_qp_wr;
+	rxe->attr.device_cap_flags		= RXE_DEVICE_CAP_FLAGS;
+	rxe->attr.max_sge			= RXE_MAX_SGE;
+	rxe->attr.max_sge_rd			= RXE_MAX_SGE_RD;
+	rxe->attr.max_cq			= rxe_max_cq;
+	if ((rxe_max_log_cqe < 0) || (rxe_max_log_cqe > 20))
+		rxe_max_log_cqe = RXE_MAX_LOG_CQE;
+	rxe->attr.max_cqe			= (1 << rxe_max_log_cqe) - 1;
+	rxe->attr.max_mr			= rxe_max_mr;
+	rxe->attr.max_pd			= RXE_MAX_PD;
+	rxe->attr.max_qp_rd_atom		= RXE_MAX_QP_RD_ATOM;
+	rxe->attr.max_ee_rd_atom		= RXE_MAX_EE_RD_ATOM;
+	rxe->attr.max_res_rd_atom		= RXE_MAX_RES_RD_ATOM;
+	rxe->attr.max_qp_init_rd_atom		= RXE_MAX_QP_INIT_RD_ATOM;
+	rxe->attr.max_ee_init_rd_atom		= RXE_MAX_EE_INIT_RD_ATOM;
+	rxe->attr.atomic_cap			= RXE_ATOMIC_CAP;
+	rxe->attr.max_ee			= RXE_MAX_EE;
+	rxe->attr.max_rdd			= RXE_MAX_RDD;
+	rxe->attr.max_mw			= rxe_max_mw;
+	rxe->attr.max_raw_ipv6_qp		= RXE_MAX_RAW_IPV6_QP;
+	rxe->attr.max_raw_ethy_qp		= RXE_MAX_RAW_ETHY_QP;
+	rxe->attr.max_mcast_grp			= RXE_MAX_MCAST_GRP;
+	rxe->attr.max_mcast_qp_attach		= RXE_MAX_MCAST_QP_ATTACH;
+	rxe->attr.max_total_mcast_qp_attach	= RXE_MAX_TOT_MCAST_QP_ATTACH;
+	rxe->attr.max_ah			= RXE_MAX_AH;
+	rxe->attr.max_fmr			= rxe_max_fmr;
+	rxe->attr.max_map_per_fmr		= RXE_MAX_MAP_PER_FMR;
+	rxe->attr.max_srq			= RXE_MAX_SRQ;
+	rxe->attr.max_srq_wr			= RXE_MAX_SRQ_WR;
+	rxe->attr.max_srq_sge			= RXE_MAX_SRQ_SGE;
+	rxe->attr.max_fast_reg_page_list_len	= RXE_MAX_FMR_PAGE_LIST_LEN;
+	rxe->attr.max_pkeys			= RXE_MAX_PKEYS;
+	rxe->attr.local_ca_ack_delay		= RXE_LOCAL_CA_ACK_DELAY;
+
+	rxe->max_ucontext			= rxe_max_ucontext;
+	rxe->pref_mtu = rxe_mtu_int_to_enum(rxe_default_mtu);
+
+	return 0;
+}
+
+/* initialize port attributes */
+static int rxe_init_port_param(struct rxe_dev *rxe, unsigned int port_num)
+{
+	struct rxe_port *port = &rxe->port[port_num - 1];
+
+	port->attr.state		= RXE_PORT_STATE;
+	port->attr.max_mtu		= RXE_PORT_MAX_MTU;
+	port->attr.active_mtu		= RXE_PORT_ACTIVE_MTU;
+	port->attr.gid_tbl_len		= RXE_PORT_GID_TBL_LEN;
+	port->attr.port_cap_flags	= RXE_PORT_PORT_CAP_FLAGS;
+	port->attr.max_msg_sz		= RXE_PORT_MAX_MSG_SZ;
+	port->attr.bad_pkey_cntr	= RXE_PORT_BAD_PKEY_CNTR;
+	port->attr.qkey_viol_cntr	= RXE_PORT_QKEY_VIOL_CNTR;
+	port->attr.pkey_tbl_len		= RXE_PORT_PKEY_TBL_LEN;
+	port->attr.lid			= RXE_PORT_LID;
+	port->attr.sm_lid		= RXE_PORT_SM_LID;
+	port->attr.lmc			= RXE_PORT_LMC;
+	port->attr.max_vl_num		= RXE_PORT_MAX_VL_NUM;
+	port->attr.sm_sl		= RXE_PORT_SM_SL;
+	port->attr.subnet_timeout	= RXE_PORT_SUBNET_TIMEOUT;
+	port->attr.init_type_reply	= RXE_PORT_INIT_TYPE_REPLY;
+	port->attr.active_width		= RXE_PORT_ACTIVE_WIDTH;
+	port->attr.active_speed		= RXE_PORT_ACTIVE_SPEED;
+	port->attr.phys_state		= RXE_PORT_PHYS_STATE;
+	port->mtu_cap			=
+				rxe_mtu_enum_to_int(RXE_PORT_ACTIVE_MTU);
+	port->subnet_prefix		= cpu_to_be64(RXE_PORT_SUBNET_PREFIX);
+
+	return 0;
+}
+
+/* initialize port state, note IB convention
+   that HCA ports are always numbered from 1 */
+static int rxe_init_ports(struct rxe_dev *rxe)
+{
+	int err;
+	unsigned int port_num;
+	struct rxe_port *port;
+
+	rxe->port = kcalloc(rxe->num_ports, sizeof(struct rxe_port),
+			    GFP_KERNEL);
+	if (!rxe->port)
+		return -ENOMEM;
+
+	for (port_num = 1; port_num <= rxe->num_ports; port_num++) {
+		port = &rxe->port[port_num - 1];
+
+		rxe_init_port_param(rxe, port_num);
+
+		if (!port->attr.pkey_tbl_len) {
+			err = -EINVAL;
+			goto err1;
+		}
+
+		port->pkey_tbl = kcalloc(port->attr.pkey_tbl_len,
+					 sizeof(*port->pkey_tbl), GFP_KERNEL);
+		if (!port->pkey_tbl) {
+			err = -ENOMEM;
+			goto err1;
+		}
+
+		port->pkey_tbl[0] = 0xffff;
+
+		if (!port->attr.gid_tbl_len) {
+			kfree(port->pkey_tbl);
+			err = -EINVAL;
+			goto err1;
+		}
+
+		port->guid_tbl = kcalloc(port->attr.gid_tbl_len,
+					 sizeof(*port->guid_tbl), GFP_KERNEL);
+		if (!port->guid_tbl) {
+			kfree(port->pkey_tbl);
+			err = -ENOMEM;
+			goto err1;
+		}
+
+		port->guid_tbl[0] = rxe->ifc_ops->port_guid(rxe, port_num);
+
+		spin_lock_init(&port->port_lock);
+	}
+
+	return 0;
+
+err1:
+	while (--port_num >= 1) {
+		port = &rxe->port[port_num - 1];
+		kfree(port->pkey_tbl);
+		kfree(port->guid_tbl);
+	}
+
+	kfree(rxe->port);
+	return err;
+}
+
+/* init pools of managed objects */
+static int rxe_init_pools(struct rxe_dev *rxe)
+{
+	int err;
+
+	err = rxe_pool_init(rxe, &rxe->uc_pool, RXE_TYPE_UC,
+			     rxe->max_ucontext);
+	if (err)
+		goto err1;
+
+	err = rxe_pool_init(rxe, &rxe->pd_pool, RXE_TYPE_PD,
+			     rxe->attr.max_pd);
+	if (err)
+		goto err2;
+
+	err = rxe_pool_init(rxe, &rxe->ah_pool, RXE_TYPE_AH,
+			     rxe->attr.max_ah);
+	if (err)
+		goto err3;
+
+	err = rxe_pool_init(rxe, &rxe->srq_pool, RXE_TYPE_SRQ,
+			     rxe->attr.max_srq);
+	if (err)
+		goto err4;
+
+	err = rxe_pool_init(rxe, &rxe->qp_pool, RXE_TYPE_QP,
+			     rxe->attr.max_qp);
+	if (err)
+		goto err5;
+
+	err = rxe_pool_init(rxe, &rxe->cq_pool, RXE_TYPE_CQ,
+			     rxe->attr.max_cq);
+	if (err)
+		goto err6;
+
+	err = rxe_pool_init(rxe, &rxe->mr_pool, RXE_TYPE_MR,
+			     rxe->attr.max_mr);
+	if (err)
+		goto err7;
+
+	err = rxe_pool_init(rxe, &rxe->fmr_pool, RXE_TYPE_FMR,
+			     rxe->attr.max_fmr);
+	if (err)
+		goto err8;
+
+	err = rxe_pool_init(rxe, &rxe->mw_pool, RXE_TYPE_MW,
+			     rxe->attr.max_mw);
+	if (err)
+		goto err9;
+
+	err = rxe_pool_init(rxe, &rxe->mc_grp_pool, RXE_TYPE_MC_GRP,
+			     rxe->attr.max_mcast_grp);
+	if (err)
+		goto err10;
+
+	err = rxe_pool_init(rxe, &rxe->mc_elem_pool, RXE_TYPE_MC_ELEM,
+			     rxe->attr.max_total_mcast_qp_attach);
+	if (err)
+		goto err11;
+
+	return 0;
+
+err11:
+	rxe_pool_cleanup(&rxe->mc_grp_pool);
+err10:
+	rxe_pool_cleanup(&rxe->mw_pool);
+err9:
+	rxe_pool_cleanup(&rxe->fmr_pool);
+err8:
+	rxe_pool_cleanup(&rxe->mr_pool);
+err7:
+	rxe_pool_cleanup(&rxe->cq_pool);
+err6:
+	rxe_pool_cleanup(&rxe->qp_pool);
+err5:
+	rxe_pool_cleanup(&rxe->srq_pool);
+err4:
+	rxe_pool_cleanup(&rxe->ah_pool);
+err3:
+	rxe_pool_cleanup(&rxe->pd_pool);
+err2:
+	rxe_pool_cleanup(&rxe->uc_pool);
+err1:
+	return err;
+}
+
+/* initialize rxe device state */
+static int rxe_init(struct rxe_dev *rxe)
+{
+	int err;
+
+	/* init default device parameters */
+	rxe_init_device_param(rxe);
+
+	err = rxe_init_ports(rxe);
+	if (err)
+		goto err1;
+
+	err = rxe_init_pools(rxe);
+	if (err)
+		goto err2;
+
+	/* init packet counters */
+	atomic_set(&rxe->req_skb_in, 0);
+	atomic_set(&rxe->resp_skb_in, 0);
+	atomic_set(&rxe->req_skb_out, 0);
+	atomic_set(&rxe->resp_skb_out, 0);
+
+	/* init pending mmap list */
+	spin_lock_init(&rxe->mmap_offset_lock);
+	spin_lock_init(&rxe->pending_lock);
+	INIT_LIST_HEAD(&rxe->pending_mmaps);
+
+	/* init arbiter */
+	spin_lock_init(&rxe->arbiter.list_lock);
+	INIT_LIST_HEAD(&rxe->arbiter.qp_list);
+	rxe_init_task(rxe, &rxe->arbiter.task, &rxe_fast_arb,
+		      rxe, rxe_arbiter, "arb");
+
+	return 0;
+
+err2:
+	rxe_cleanup_ports(rxe);
+err1:
+	return err;
+}
+
+int rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu,
+		unsigned int port_num)
+{
+	struct rxe_port *port = &rxe->port[port_num - 1];
+	enum rxe_mtu mtu;
+
+	mtu = eth_mtu_int_to_enum(ndev_mtu);
+	if (!mtu)
+		return -EINVAL;
+
+	/* Set the port mtu to min(feasible, preferred) */
+	mtu = min_t(enum rxe_mtu, mtu, rxe->pref_mtu);
+
+	port->attr.active_mtu = (enum ib_mtu __force)mtu;
+	port->mtu_cap = rxe_mtu_enum_to_int(mtu);
+
+	return 0;
+}
+EXPORT_SYMBOL(rxe_set_mtu);
+
+/* called by ifc layer to create new rxe device
+   caller should allocate memory for rxe by calling
+   ib_alloc_device */
+int rxe_add(struct rxe_dev *rxe, unsigned int mtu)
+{
+	int err;
+	unsigned port_num = 1;
+
+	__module_get(THIS_MODULE);
+
+	kref_init(&rxe->ref_cnt);
+
+	err = rxe_init(rxe);
+	if (err)
+		goto err1;
+
+	err = rxe_set_mtu(rxe, mtu, port_num);
+	if (err)
+		goto err2;
+
+	err = rxe_register_device(rxe);
+	if (err)
+		goto err2;
+
+	return 0;
+
+err2:
+	rxe_cleanup(rxe);
+err1:
+	kref_put(&rxe->ref_cnt, rxe_release);
+	module_put(THIS_MODULE);
+	return err;
+}
+EXPORT_SYMBOL(rxe_add);
+
+/* called by the ifc layer to remove a device */
+void rxe_remove(struct rxe_dev *rxe)
+{
+	rxe_unregister_device(rxe);
+
+	kref_put(&rxe->ref_cnt, rxe_release);
+}
+EXPORT_SYMBOL(rxe_remove);
+
+static int __init rxe_module_init(void)
+{
+	int err;
+
+	/* initialize slab caches for managed objects */
+	err = rxe_cache_init();
+	if (err) {
+		pr_err("rxe: unable to init object pools\n");
+		return err;
+	}
+
+	pr_info("rxe: loaded\n");
+
+	return 0;
+}
+
+static void __exit rxe_module_exit(void)
+{
+	rxe_cache_exit();
+
+	pr_info("rxe: unloaded\n");
+}
+
+module_init(rxe_module_init);
+module_exit(rxe_module_exit);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20110724201229.666252623-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org

#96 lore raw

Re: [patch v2 31/37] add rxe.c

Quoted 9 lines · On Sun, Jul 24, 2011 at 9:43 PM, <rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@pu…
drivers/infiniband/hw/rxe/rxe.c new file +9 -0
+int rxe_fast_comp = 2;
+module_param_named(fast_comp, rxe_fast_comp, int, 0644);
+MODULE_PARM_DESC(fast_comp, "fast path call to completer "
+		 "(0=no, 1=no int context, 2=any context)");
+
+int rxe_fast_resp = 2;
+module_param_named(fast_resp, rxe_fast_resp, int, 0644);
+MODULE_PARM_DESC(fast_resp, "enable fast path call to responder "
+		 "(0=no, 1=no int context, 2=any context)");

drivers/infiniband/hw/rxe/rxe.c line 95

Quoted 10 lines
drivers/infiniband/hw/rxe/rxe.c new file +10 -0
+
+int rxe_fast_req = 2;
+module_param_named(fast_req, rxe_fast_req, int, 0644);
+MODULE_PARM_DESC(fast_req, "enable fast path call to requester "
+		 "(0=no, 1=no int context, 2=any context)");
+
+int rxe_fast_arb = 2;
+module_param_named(fast_arb, rxe_fast_arb, int, 0644);
+MODULE_PARM_DESC(fast_arb, "enable fast path call to arbiter "
+		 "(0=no, 1=no int context, 2=any context)");

The ib_rxe kernel module has an impressive number of module parameters. I have been wondering whether it's possible to reduce that number somewhat. As an example, is it necessary that all four kernel module parameters mentioned above can be configured individually ? As far as I can see the only purpose of these parameters is to make it possible to move processing of certain events from interrupt to tasklet or process context. How about using one kernel module parameter for that purpose instead of four ?

Quoted 53 lines
drivers/infiniband/hw/rxe/rxe.c new file +53 -0
+/* initialize port state, note IB convention
+   that HCA ports are always numbered from 1 */
+static int rxe_init_ports(struct rxe_dev *rxe)
+{
+	int err;
+	unsigned int port_num;
+	struct rxe_port *port;
+
+	rxe->port = kcalloc(rxe->num_ports, sizeof(struct rxe_port),
+			    GFP_KERNEL);
+	if (!rxe->port)
+		return -ENOMEM;
+
+	for (port_num = 1; port_num <= rxe->num_ports; port_num++) {
+		port = &rxe->port[port_num - 1];
+
+		rxe_init_port_param(rxe, port_num);
+
+		if (!port->attr.pkey_tbl_len) {
+			err = -EINVAL;
+			goto err1;
+		}
+
+		port->pkey_tbl = kcalloc(port->attr.pkey_tbl_len,
+					 sizeof(*port->pkey_tbl), GFP_KERNEL);
+		if (!port->pkey_tbl) {
+			err = -ENOMEM;
+			goto err1;
+		}
+
+		port->pkey_tbl[0] = 0xffff;
+
+		if (!port->attr.gid_tbl_len) {
+			kfree(port->pkey_tbl);
+			err = -EINVAL;
+			goto err1;
+		}
+
+		port->guid_tbl = kcalloc(port->attr.gid_tbl_len,
+					 sizeof(*port->guid_tbl), GFP_KERNEL);
+		if (!port->guid_tbl) {
+			kfree(port->pkey_tbl);
+			err = -ENOMEM;
+			goto err1;
+		}
+
+		port->guid_tbl[0] = rxe->ifc_ops->port_guid(rxe, port_num);
+
+		spin_lock_init(&port->port_lock);
+	}
+
+	return 0;
+

drivers/infiniband/hw/rxe/rxe.c line 332

Quoted 10 lines
drivers/infiniband/hw/rxe/rxe.c new file +10 -0
+err1:
+	while (--port_num >= 1) {
+		port = &rxe->port[port_num - 1];
+		kfree(port->pkey_tbl);
+		kfree(port->guid_tbl);
+	}
+
+	kfree(rxe->port);
+	return err;
+}

Same remark here about the "err" variable and the "err1" label - that seems confusing to me.

Quoted 9 lines
drivers/infiniband/hw/rxe/rxe.c new file +9 -0
+int rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu,
+		unsigned int port_num)
+{
+	struct rxe_port *port = &rxe->port[port_num - 1];
+	enum rxe_mtu mtu;
+
+	mtu = eth_mtu_int_to_enum(ndev_mtu);
+	if (!mtu)
+		return -EINVAL;

drivers/infiniband/hw/rxe/rxe.c line 479

Quoted 10 lines
drivers/infiniband/hw/rxe/rxe.c new file +10 -0
+
+	/* Set the port mtu to min(feasible, preferred) */
+	mtu = min_t(enum rxe_mtu, mtu, rxe->pref_mtu);
+
+	port->attr.active_mtu = (enum ib_mtu __force)mtu;
+	port->mtu_cap = rxe_mtu_enum_to_int(mtu);
+
+	return 0;
+}
+EXPORT_SYMBOL(rxe_set_mtu);

Sorry, but using the datatype "enum rxe_mtu" for an MTU doesn't make sense to me. Shouldn't that be "int" instead ?

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#97 lore raw

PATCH v2 32/37 add rxe_net.h

In reply to [email protected]

Common declarations for ib_rxe_net module.

---
 drivers/infiniband/hw/rxe/rxe_net.h |   86 ++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
drivers/infiniband/hw/rxe/rxe_net.h new file +86 -0
Index: infiniband/drivers/infiniband/hw/rxe/rxe_net.h
===================================================================
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *	- Redistributions of source code must retain the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer.
+ *
+ *	- Redistributions in binary form must reproduce the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer in the documentation and/or other materials
+ *	  provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef RXE_NET_H
+#define RXE_NET_H
+
+#include <net/sock.h>
+#include <net/if_inet6.h>
+
+/*
+ * this should be defined in .../include/linux/if_ether.h
+ */
+#define ETH_P_RXE			(0x8915)
+
+/*
+ * this should be defined in .../include/linux/netfilter.h
+ * to a specific value
+ */
+#define NFPROTO_RXE			(0)
+
+/*
+ * these should be defined in .../include/linux/netfilter_rxe.h
+ */
+#define NF_RXE_IN			(0)
+#define NF_RXE_OUT			(1)
+
+/* Should probably move to something other than an array...these can be big */
+#define RXE_MAX_IF_INDEX	(384)
+
+struct rxe_net_info {
+	struct rxe_dev		*rxe;
+	u8			port;
+	struct net_device	*ndev;
+	int			status;
+};
+
+extern struct rxe_net_info net_info[RXE_MAX_IF_INDEX];
+extern spinlock_t net_info_lock;
+
+/* caller must hold net_dev_lock */
+static inline struct rxe_dev *net_to_rxe(struct net_device *ndev)
+{
+	return (ndev->ifindex >= RXE_MAX_IF_INDEX) ?
+		NULL : net_info[ndev->ifindex].rxe;
+}
+
+static inline u8 net_to_port(struct net_device *ndev)
+{
+	return net_info[ndev->ifindex].port;
+}
+
+void rxe_net_add(struct net_device *ndev);
+void rxe_net_up(struct net_device *ndev);
+void rxe_net_down(struct net_device *ndev);
+
+#endif /* RXE_NET_H */

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20110724201229.715886208-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org

#99 lore raw

Re: [patch v2 32/37] add rxe_net.h

Quoted 6 lines · On Sun, Jul 24, 2011 at 9:43 PM, <rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@pu…
drivers/infiniband/hw/rxe/rxe_net.h new file +6 -0
+/*
+ * this should be defined in .../include/linux/if_ether.h
+ */
+#define ETH_P_RXE			(0x8915)
+
+/*

drivers/infiniband/hw/rxe/rxe_net.h line 55

Quoted 10 lines
drivers/infiniband/hw/rxe/rxe_net.h new file +10 -0
+ * this should be defined in .../include/linux/netfilter.h
+ * to a specific value
+ */
+#define NFPROTO_RXE			(0)
+
+/*
+ * these should be defined in .../include/linux/netfilter_rxe.h
+ */
+#define NF_RXE_IN			(0)
+#define NF_RXE_OUT			(1)

Please update the cited header files instead of adding these symbols here.

drivers/infiniband/hw/rxe/rxe_net.h line 58

Quoted 2 lines
drivers/infiniband/hw/rxe/rxe_net.h new file +2 -0
+/* Should probably move to something other than an array...these can be big */
+#define RXE_MAX_IF_INDEX	(384)

Has it been considered to change net_info[] from an array into a linked list ? As far as I can see none of the net_info[] accesses are in the fast path and the number of entries used in the (sparse) net_info[] array is small. Such a change would allow to eliminate the RXE_MAX_IF_INDEX artificial limit.

drivers/infiniband/hw/rxe/rxe_net.h line 65

Quoted 6 lines
drivers/infiniband/hw/rxe/rxe_net.h new file +6 -0
+struct rxe_net_info {
+	struct rxe_dev		*rxe;
+	u8			port;
+	struct net_device	*ndev;
+	int			status;
+};

Is there a reason why status and port are in struct rxe_net_info instead of struct rxe_dev ? Moving these two fields would allow several code simplifications IMHO.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#100 lore raw

PATCH v2 33/37 add rxe_net.c

In reply to [email protected]

implements kernel module that implements an interface between ib_rxe and the netdev stack.

---
 drivers/infiniband/hw/rxe/rxe_net.c |  580 ++++++++++++++++++++++++++++++++++++
 1 file changed, 580 insertions(+)
drivers/infiniband/hw/rxe/rxe_net.c new file +580 -0
Index: infiniband/drivers/infiniband/hw/rxe/rxe_net.c
===================================================================
@@ -0,0 +1,580 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *	- Redistributions of source code must retain the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer.
+ *
+ *	- Redistributions in binary form must reproduce the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer in the documentation and/or other materials
+ *	  provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/if.h>
+#include <linux/if_vlan.h>
+#include <net/sch_generic.h>
+#include <linux/netfilter.h>
+#include <rdma/ib_addr.h>
+
+#include "rxe.h"
+#include "rxe_net.h"
+
+MODULE_AUTHOR("Bob Pearson, Frank Zago, John Groves");
+MODULE_DESCRIPTION("RDMA transport over Converged Enhanced Ethernet");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static int rxe_eth_proto_id = ETH_P_RXE;
+module_param_named(eth_proto_id, rxe_eth_proto_id, int, 0644);
+MODULE_PARM_DESC(eth_proto_id, "Ethernet protocol ID (default/correct=0x8915)");
+
+static int rxe_xmit_shortcut;
+module_param_named(xmit_shortcut, rxe_xmit_shortcut, int, 0644);
+MODULE_PARM_DESC(xmit_shortcut,
+		 "Shortcut transmit (EXPERIMENTAL)");
+
+static int rxe_loopback_mad_grh_fix = 1;
+module_param_named(loopback_mad_grh_fix, rxe_loopback_mad_grh_fix, int, 0644);
+MODULE_PARM_DESC(loopback_mad_grh_fix, "Allow MADs to self without GRH");
+
+/*
+ * note: this table is a replacement for a protocol specific pointer
+ * in struct net_device which exists for other ethertypes
+ * this allows us to not have to patch that data structure
+ * eventually we want to get our own when we're famous
+ */
+struct rxe_net_info net_info[RXE_MAX_IF_INDEX];
+spinlock_t net_info_lock;
+
+static int rxe_net_rcv(struct sk_buff *skb,
+		       struct net_device *ndev,
+		       struct packet_type *ptype,
+		       struct net_device *orig_dev);
+
+static __be64 rxe_mac_to_eui64(struct net_device *ndev)
+{
+	unsigned char *mac_addr = ndev->dev_addr;
+	__be64 eui64;
+	unsigned char *dst = (unsigned char *)&eui64;
+
+	dst[0] = mac_addr[0] ^ 2;
+	dst[1] = mac_addr[1];
+	dst[2] = mac_addr[2];
+	dst[3] = 0xff;
+	dst[4] = 0xfe;
+	dst[5] = mac_addr[3];
+	dst[6] = mac_addr[4];
+	dst[7] = mac_addr[5];
+
+	return eui64;
+}
+
+/* callback when rxe gets released */
+static void release(struct rxe_dev *rxe)
+{
+	module_put(THIS_MODULE);
+}
+
+static __be64 node_guid(struct rxe_dev *rxe)
+{
+	return rxe_mac_to_eui64(rxe->ndev);
+}
+
+static __be64 port_guid(struct rxe_dev *rxe, unsigned int port_num)
+{
+	return rxe_mac_to_eui64(rxe->ndev);
+}
+
+static struct device *dma_device(struct rxe_dev *rxe)
+{
+	struct net_device *ndev;
+
+	ndev = rxe->ndev;
+
+	if (ndev->priv_flags & IFF_802_1Q_VLAN)
+		ndev = vlan_dev_real_dev(ndev);
+
+	return ndev->dev.parent;
+}
+
+static int mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+	int err;
+	unsigned char ll_addr[ETH_ALEN];
+
+	ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr);
+	err = dev_mc_add(rxe->ndev, ll_addr);
+
+	return err;
+}
+
+static int mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+	int err;
+	unsigned char ll_addr[ETH_ALEN];
+
+	ipv6_eth_mc_map((struct in6_addr *)mgid->raw, ll_addr);
+	err = dev_mc_del(rxe->ndev, ll_addr);
+
+	return err;
+}
+
+static inline int queue_deactivated(struct sk_buff *skb)
+{
+	const struct net_device_ops *ops = skb->dev->netdev_ops;
+	u16 queue_index = 0;
+	struct netdev_queue *txq;
+
+	if (ops->ndo_select_queue)
+		queue_index = ops->ndo_select_queue(skb->dev, skb);
+	else if (skb->dev->real_num_tx_queues > 1)
+		queue_index = skb_tx_hash(skb->dev, skb);
+
+	txq = netdev_get_tx_queue(skb->dev, queue_index);
+	return txq->qdisc->state & 2;
+}
+
+static int send_finish(struct sk_buff *skb)
+{
+	if (!rxe_xmit_shortcut)
+		return dev_queue_xmit(skb);
+	else
+		return skb->dev->netdev_ops->ndo_start_xmit(skb, skb->dev);
+}
+
+static int send(struct rxe_dev *rxe, struct sk_buff *skb)
+{
+	if (queue_deactivated(skb))
+		return RXE_QUEUE_STOPPED;
+
+	if (netif_queue_stopped(skb->dev))
+		return RXE_QUEUE_STOPPED;
+
+	return NF_HOOK(NFPROTO_RXE, NF_RXE_OUT, skb, rxe->ndev, NULL,
+		send_finish);
+}
+
+static int loopback_finish(struct sk_buff *skb)
+{
+	struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
+	struct packet_type *ptype = NULL;
+	struct net_device *orig_dev = pkt->rxe->ndev;
+
+	return rxe_net_rcv(skb, pkt->rxe->ndev, ptype, orig_dev);
+}
+
+static int loopback(struct rxe_dev *rxe, struct sk_buff *skb)
+{
+	return NF_HOOK(NFPROTO_RXE, NF_RXE_OUT, skb, rxe->ndev, NULL,
+		loopback_finish);
+}
+
+static inline int addr_same(struct rxe_dev *rxe, struct rxe_av *av)
+{
+	int port_num = 1;
+	return rxe->port[port_num - 1].guid_tbl[0]
+			== av->attr.grh.dgid.global.interface_id;
+}
+
+static struct sk_buff *init_packet(struct rxe_dev *rxe, struct rxe_av *av,
+				   int paylen)
+{
+	struct sk_buff *skb;
+	struct rxe_pkt_info *pkt;
+
+
+	skb = alloc_skb(paylen + RXE_GRH_BYTES + LL_RESERVED_SPACE(rxe->ndev),
+			GFP_ATOMIC);
+	if (!skb)
+		return NULL;
+
+	skb_reserve(skb, LL_RESERVED_SPACE(rxe->ndev));
+	skb_reset_network_header(skb);
+
+	skb->dev	= rxe->ndev;
+	skb->protocol	= htons(rxe_eth_proto_id);
+
+	pkt		= SKB_TO_PKT(skb);
+	pkt->rxe	= rxe;
+	pkt->port_num	= 1;
+	pkt->hdr	= skb_put(skb, RXE_GRH_BYTES + paylen);
+	pkt->mask	= RXE_GRH_MASK;
+
+	dev_hard_header(skb, rxe->ndev, rxe_eth_proto_id,
+			av->ll_addr, rxe->ndev->dev_addr, skb->len);
+
+	if (addr_same(rxe, av))
+		pkt->mask |= RXE_LOOPBACK_MASK;
+
+	return skb;
+}
+
+static int init_av(struct rxe_dev *rxe, struct ib_ah_attr *attr,
+		   struct rxe_av *av)
+{
+	struct in6_addr *in6 = (struct in6_addr *)attr->grh.dgid.raw;
+
+	/* grh required for rxe_net */
+	if ((attr->ah_flags & IB_AH_GRH) == 0) {
+		if (rxe_loopback_mad_grh_fix) {
+			/* temporary fix so that we can handle mad's to self
+			   without grh's included add grh pointing to self */
+			attr->ah_flags |= IB_AH_GRH;
+			attr->grh.dgid.global.subnet_prefix
+				= rxe->port[0].subnet_prefix;
+			attr->grh.dgid.global.interface_id
+				= rxe->port[0].guid_tbl[0];
+			av->attr = *attr;
+		} else {
+			pr_info("rxe_net: attempting to init av without grh\n");
+			return -EINVAL;
+		}
+	}
+
+	if (rdma_link_local_addr(in6))
+		rdma_get_ll_mac(in6, av->ll_addr);
+	else if (rdma_is_multicast_addr(in6))
+		rdma_get_mcast_mac(in6, av->ll_addr);
+	else {
+		int i;
+		char addr[64];
+
+		for (i = 0; i < 16; i++)
+			sprintf(addr+2*i, "%02x", attr->grh.dgid.raw[i]);
+
+		pr_info("rxe_net: non local subnet address not supported %s\n",
+			addr);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/*
+ * this is required by rxe_cfg to match rxe devices in
+ * /sys/class/infiniband up with their underlying ethernet devices
+ */
+static char *parent_name(struct rxe_dev *rxe, unsigned int port_num)
+{
+	return rxe->ndev->name;
+}
+
+static enum rdma_link_layer link_layer(struct rxe_dev *rxe,
+				       unsigned int port_num)
+{
+	return IB_LINK_LAYER_ETHERNET;
+}
+
+static struct rxe_ifc_ops ifc_ops = {
+	.release	= release,
+	.node_guid	= node_guid,
+	.port_guid	= port_guid,
+	.dma_device	= dma_device,
+	.mcast_add	= mcast_add,
+	.mcast_delete	= mcast_delete,
+	.send		= send,
+	.loopback	= loopback,
+	.init_packet	= init_packet,
+	.init_av	= init_av,
+	.parent_name	= parent_name,
+	.link_layer	= link_layer,
+};
+
+/* Caller must hold net_info_lock */
+void rxe_net_add(struct net_device *ndev)
+{
+	int err;
+	struct rxe_dev *rxe;
+	unsigned port_num;
+
+	__module_get(THIS_MODULE);
+
+	rxe = (struct rxe_dev *)ib_alloc_device(sizeof(*rxe));
+	if (!rxe) {
+		err = -ENOMEM;
+		goto err1;
+	}
+
+	/* for now we always assign port = 1 */
+	port_num = 1;
+
+	rxe->ifc_ops = &ifc_ops;
+
+	rxe->ndev = ndev;
+
+	err = rxe_add(rxe, ndev->mtu);
+	if (err)
+		goto err2;
+
+	pr_info("rxe_net: added %s to %s\n",
+		 rxe->ib_dev.name, ndev->name);
+
+	net_info[ndev->ifindex].rxe = rxe;
+	net_info[ndev->ifindex].port = port_num;
+	net_info[ndev->ifindex].ndev = ndev;
+	return;
+
+err2:
+	ib_dealloc_device(&rxe->ib_dev);
+err1:
+	module_put(THIS_MODULE);
+
+	return;
+}
+
+/* Caller must hold net_info_lock */
+void rxe_net_up(struct net_device *ndev)
+{
+	struct rxe_dev *rxe;
+	struct rxe_port *port;
+	u8 port_num;
+
+	if (ndev->ifindex >= RXE_MAX_IF_INDEX)
+		goto out;
+
+	net_info[ndev->ifindex].status = IB_PORT_ACTIVE;
+
+	rxe = net_to_rxe(ndev);
+	if (!rxe)
+		goto out;
+
+	port_num = net_to_port(ndev);
+	port = &rxe->port[port_num-1];
+	port->attr.state = IB_PORT_ACTIVE;
+	port->attr.phys_state = IB_PHYS_STATE_LINK_UP;
+
+	pr_info("rxe_net: set %s active for %s\n",
+		rxe->ib_dev.name, ndev->name);
+out:
+	return;
+}
+
+/* Caller must hold net_info_lock */
+void rxe_net_down(struct net_device *ndev)
+{
+	struct rxe_dev *rxe;
+	struct rxe_port *port;
+	u8 port_num;
+
+	if (ndev->ifindex >= RXE_MAX_IF_INDEX)
+		goto out;
+
+	net_info[ndev->ifindex].status = IB_PORT_DOWN;
+
+	rxe = net_to_rxe(ndev);
+	if (!rxe)
+		goto out;
+
+	port_num = net_to_port(ndev);
+	port = &rxe->port[port_num-1];
+	port->attr.state = IB_PORT_DOWN;
+	port->attr.phys_state = 3;
+
+	pr_info("rxe_net: set %s down for %s\n",
+		rxe->ib_dev.name, ndev->name);
+out:
+	return;
+}
+
+static int can_support_rxe(struct net_device *ndev)
+{
+	int rc = 0;
+
+	if (ndev->ifindex >= RXE_MAX_IF_INDEX) {
+		pr_debug("%s index %d: too large for rxe ndev table\n",
+			 ndev->name, ndev->ifindex);
+		goto out;
+	}
+
+	/* Let's says we support all ethX devices */
+	if (strncmp(ndev->name, "eth", 3) == 0)
+		rc = 1;
+
+out:
+	return rc;
+}
+
+static int rxe_notify(struct notifier_block *not_blk,
+		      unsigned long event,
+		      void *arg)
+{
+	struct net_device *ndev = arg;
+	struct rxe_dev *rxe;
+
+	if (!can_support_rxe(ndev))
+		goto out;
+
+	spin_lock_bh(&net_info_lock);
+	switch (event) {
+	case NETDEV_REGISTER:
+		/* Keep a record of this NIC. */
+		net_info[ndev->ifindex].status = IB_PORT_DOWN;
+		net_info[ndev->ifindex].rxe = NULL;
+		net_info[ndev->ifindex].port = 1;
+		net_info[ndev->ifindex].ndev = ndev;
+		break;
+
+	case NETDEV_UNREGISTER:
+		if (net_info[ndev->ifindex].rxe) {
+			rxe = net_info[ndev->ifindex].rxe;
+			net_info[ndev->ifindex].rxe = NULL;
+			spin_unlock_bh(&net_info_lock);
+			rxe_remove(rxe);
+			spin_lock_bh(&net_info_lock);
+		}
+		net_info[ndev->ifindex].status = 0;
+		net_info[ndev->ifindex].port = 0;
+		net_info[ndev->ifindex].ndev = NULL;
+		break;
+
+	case NETDEV_UP:
+		rxe_net_up(ndev);
+		break;
+
+	case NETDEV_DOWN:
+		rxe_net_down(ndev);
+		break;
+
+	case NETDEV_CHANGEMTU:
+		rxe = net_to_rxe(ndev);
+		if (rxe) {
+			pr_info("rxe_net: %s changed mtu to %d\n",
+				ndev->name, ndev->mtu);
+			rxe_set_mtu(rxe, ndev->mtu, net_to_port(ndev));
+		}
+		break;
+
+	case NETDEV_REBOOT:
+	case NETDEV_CHANGE:
+	case NETDEV_GOING_DOWN:
+	case NETDEV_CHANGEADDR:
+	case NETDEV_CHANGENAME:
+	case NETDEV_FEAT_CHANGE:
+	default:
+		pr_info("rxe_net: ignoring netdev event = %ld for %s\n",
+			event, ndev->name);
+		break;
+	}
+	spin_unlock_bh(&net_info_lock);
+
+out:
+	return NOTIFY_OK;
+}
+
+static int rxe_net_rcv(struct sk_buff *skb,
+		       struct net_device *ndev,
+		       struct packet_type *ptype,
+		       struct net_device *orig_dev)
+{
+	struct rxe_dev *rxe = net_to_rxe(ndev);
+	struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
+	int rc = 0;
+
+	if (!rxe)
+		goto drop;
+
+	/* TODO: We can receive packets in fragments. For now we
+	 * linearize and it's costly because we may copy a lot of
+	 * data. We should handle that case better. */
+	if (skb_linearize(skb))
+		goto drop;
+
+#if 0
+	/* Error injector */
+	{
+		static int x = 8;
+		static int counter;
+		counter++;
+
+		if (counter == x) {
+			x = 13-x; /* 8 or 5 */
+			counter = 0;
+			pr_debug("dropping one packet\n");
+			goto drop;
+		}
+	}
+#endif
+
+	skb = skb_share_check(skb, GFP_ATOMIC);
+	if (!skb) {
+		/* still return null */
+		goto out;
+	}
+
+	/* set required fields in pkt */
+	pkt->rxe = rxe;
+	pkt->port_num = net_to_port(ndev);
+	pkt->hdr = skb_network_header(skb);
+	pkt->mask = RXE_GRH_MASK;
+
+	rc = NF_HOOK(NFPROTO_RXE, NF_RXE_IN, skb, ndev, NULL, rxe_rcv);
+out:
+	return rc;
+
+drop:
+	kfree_skb(skb);
+	return 0;
+}
+
+static struct packet_type rxe_packet_type = {
+	.func = rxe_net_rcv,
+};
+
+static struct notifier_block rxe_net_notifier = {
+	.notifier_call = rxe_notify,
+};
+
+static int __init rxe_net_init(void)
+{
+	int err;
+
+	spin_lock_init(&net_info_lock);
+
+	if (rxe_eth_proto_id != ETH_P_RXE)
+		pr_info("rxe_net: protoid set to 0x%x\n",
+			rxe_eth_proto_id);
+
+	rxe_packet_type.type = cpu_to_be16(rxe_eth_proto_id);
+	dev_add_pack(&rxe_packet_type);
+
+	err = register_netdevice_notifier(&rxe_net_notifier);
+
+	pr_info("rxe_net: loaded\n");
+
+	return err;
+}
+
+static void __exit rxe_net_exit(void)
+{
+	unregister_netdevice_notifier(&rxe_net_notifier);
+	dev_remove_pack(&rxe_packet_type);
+
+	pr_info("rxe_net: unloaded\n");
+
+	return;
+}
+
+module_init(rxe_net_init);
+module_exit(rxe_net_exit);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20110724201229.765038738-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org

#102 lore raw

Re: [patch v2 33/37] add rxe_net.c

On Sun, Jul 24, 2011 at 9:43 PM, <[email protected]> wrote:

(resending as plain text)

+static __be64 rxe_mac_to_eui64(struct net_device *ndev) +{

+    unsigned char *mac_addr = ndev->dev_addr;
+    __be64 eui64;
+    unsigned char *dst = (unsigned char *)&eui64;
+
+    dst[0] = mac_addr[0] ^ 2;
+    dst[1] = mac_addr[1];
+    dst[2] = mac_addr[2];
+    dst[3] = 0xff;
+    dst[4] = 0xfe;
+    dst[5] = mac_addr[3];
+    dst[6] = mac_addr[4];
+    dst[7] = mac_addr[5];

+
+ return eui64;
+}

The above is a standard EUI-48 into EUI-64 translation I assume ?

Also, I haven't found a function that does the opposite translation - does that mean that there is no GID-to-rxe-device translation in the ib_rxe driver yet ? I'd like to give ib_srp over ib_rxe a try, but as far as I can see that won't work yet ?

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAO+b5-pk-X7aGgg12ND17OLcqcLU6qyiV+vf22anh9bYsXUUzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#104 lore raw

RE: [patch v2 33/37] add rxe_net.c

Quoted 32 lines

-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Bart Van Assche
Sent: Friday, August 05, 2011 1:48 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [patch v2 33/37] add rxe_net.c

On Sun, Jul 24, 2011 at 9:43 PM, <[email protected]> wrote:

(resending as plain text)

drivers/infiniband/hw/rxe/rxe_net.c new file +17 -0
+static __be64 rxe_mac_to_eui64(struct net_device *ndev)
+{
+    unsigned char *mac_addr = ndev->dev_addr;
+    __be64 eui64;
+    unsigned char *dst = (unsigned char *)&eui64;
+
+    dst[0] = mac_addr[0] ^ 2;
+    dst[1] = mac_addr[1];
+    dst[2] = mac_addr[2];
+    dst[3] = 0xff;
+    dst[4] = 0xfe;
+    dst[5] = mac_addr[3];
+    dst[6] = mac_addr[4];
+    dst[7] = mac_addr[5];
+
+    return eui64;
+}
Quoted 1 line

The above is a standard EUI-48 into EUI-64 translation I assume ?

Yes.

Quoted 5 lines

Also, I haven't found a function that does the opposite translation - does that mean that there is no GID-to-rxe-device translation in the ib_rxe driver yet ? I'd like to give ib_srp over ib_rxe a try, but as far as I can see that won't work yet ?

There are a couple of issues with SRP/RoCE. One of them is that the current scheme for configuring connections is based on DM MADs. The other is the one you mention. We (SFW) looked at both problems a couple of years ago and came up with a version of SRP that runs over RDMACM. SRP was standardized before RDMACM was a gleam in Sean's eye and assumes that it has the entire private data area for CM MADs to pass parameters. But if you squeeze a little you can get it all in after the area that RDMACM takes. We have versions of SRPI and SRPT that can use RDMACM for connection setup. Since RDMACM supports connection setup automatically for RoCE you're all fixed. In order to make this commercially practical you would have to go back to NCITS and update the SRP standard but I'm not too sure that there is enough interest to make that happen. The other problem requires making changes to the special file that sets up the connection. We also have this patch.

If you are interested in this I would be glad to work with you to try to get these patches into OFED.

Quoted 6 lines

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#105 lore raw

Re: [patch v2 33/37] add rxe_net.c

In reply to a message not in the archive

On Sun, Jul 24, 2011 at 9:43 PM, <[email protected]> wrote:
+static __be64 rxe_mac_to_eui64(struct net_device *ndev)
+{
+    unsigned char *mac_addr = ndev->dev_addr;
+    __be64 eui64;
+    unsigned char *dst = (unsigned char *)&eui64;
+
+    dst[0] = mac_addr[0] ^ 2;
+    dst[1] = mac_addr[1];
+    dst[2] = mac_addr[2];
+    dst[3] = 0xff;
+    dst[4] = 0xfe;
+    dst[5] = mac_addr[3];
+    dst[6] = mac_addr[4];
+    dst[7] = mac_addr[5];
+
+    return eui64;
+}

As far as I can see rxe_param_set_add() does not limit ndev to Ethernet devices ? In that case my comments about the above code are as follows:
* The name mac_addr is misleading - dev_addr is probably more appropriate.
* A device address length check is missing. For network devices with addresses less than six bytes long the above code will trigger an out-of-bounds read.
* If someone binds ib_rxe to a network device with an address length above six bytes, some useful information will be discarded.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#106 lore raw

PATCH v2 34/37 add rxe_net_sysfs.c

In reply to [email protected]

sysfs interface for ib_rxe_net.

---
 drivers/infiniband/hw/rxe/rxe_net_sysfs.c |  229 ++++++++++++++++++++++++++++++
 1 file changed, 229 insertions(+)
drivers/infiniband/hw/rxe/rxe_net_sysfs.c new file +229 -0
Index: infiniband/drivers/infiniband/hw/rxe/rxe_net_sysfs.c
===================================================================
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *	- Redistributions of source code must retain the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer.
+ *
+ *	- Redistributions in binary form must reproduce the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer in the documentation and/or other materials
+ *	  provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "rxe.h"
+#include "rxe_net.h"
+
+/* Copy argument and remove trailing CR. Return the new length. */
+static int sanitize_arg(const char *val, char *intf, int intf_len)
+{
+	int len;
+
+	if (!val)
+		return 0;
+
+	/* Remove newline. */
+	for (len = 0; len < intf_len - 1 && val[len] && val[len] != '\n'; len++)
+		intf[len] = val[len];
+	intf[len] = 0;
+
+	if (len == 0 || (val[len] != 0 && val[len] != '\n'))
+		return 0;
+
+	return len;
+}
+
+/* Caller must hold net_info_lock */
+static void rxe_set_port_state(struct net_device *ndev)
+{
+	struct rxe_dev *rxe;
+
+	if (ndev->ifindex >= RXE_MAX_IF_INDEX)
+		goto out;
+
+	rxe = net_to_rxe(ndev);
+	if (!rxe)
+		goto out;
+
+	if (net_info[ndev->ifindex].status == IB_PORT_ACTIVE)
+		rxe_net_up(ndev);
+	else
+		rxe_net_down(ndev); /* down for unknown state */
+out:
+	return;
+}
+
+static int rxe_param_set_add(const char *val, struct kernel_param *kp)
+{
+	int i, len;
+	char intf[32];
+
+	len = sanitize_arg(val, intf, sizeof(intf));
+	if (!len) {
+		pr_err("rxe_net: add: invalid interface name\n");
+		return -EINVAL;
+	}
+
+	spin_lock_bh(&net_info_lock);
+	for (i = 0; i < RXE_MAX_IF_INDEX; i++) {
+		struct net_device *ndev = net_info[i].ndev;
+
+		if (ndev && (0 == strncmp(intf, ndev->name, len))) {
+			spin_unlock_bh(&net_info_lock);
+			if (net_info[i].rxe)
+				pr_info("rxe_net: already configured on %s\n",
+					intf);
+			else {
+				rxe_net_add(ndev);
+				if (net_info[i].rxe) {
+					rxe_set_port_state(ndev);
+				} else
+					pr_err("rxe_net: add appears to have "
+					       "failed for %s (index %d)\n",
+					       intf, i);
+			}
+			return 0;
+		}
+	}
+	spin_unlock_bh(&net_info_lock);
+
+	pr_warning("interface %s not found\n", intf);
+
+	return 0;
+}
+
+static void rxe_remove_all(void)
+{
+	int i;
+	struct rxe_dev *rxe;
+
+	for (i = 0; i < RXE_MAX_IF_INDEX; i++) {
+		if (net_info[i].rxe) {
+			spin_lock_bh(&net_info_lock);
+			rxe = net_info[i].rxe;
+			net_info[i].rxe = NULL;
+			spin_unlock_bh(&net_info_lock);
+
+			rxe_remove(rxe);
+		}
+	}
+}
+
+static int rxe_param_set_remove(const char *val, struct kernel_param *kp)
+{
+	int i, len;
+	char intf[32];
+	struct rxe_dev *rxe;
+
+	len = sanitize_arg(val, intf, sizeof(intf));
+	if (!len) {
+		pr_err("rxe_net: remove: invalid interface name\n");
+		return -EINVAL;
+	}
+
+	if (strncmp("all", intf, len) == 0) {
+		pr_info("rxe_sys: remove all");
+		rxe_remove_all();
+		return 0;
+	}
+
+	spin_lock_bh(&net_info_lock);
+	for (i = 0; i < RXE_MAX_IF_INDEX; i++) {
+		if (!net_info[i].rxe || !net_info[i].ndev)
+			continue;
+
+		if (0 == strncmp(intf, net_info[i].rxe->ib_dev.name, len)) {
+			rxe = net_info[i].rxe;
+			net_info[i].rxe = NULL;
+			spin_unlock_bh(&net_info_lock);
+
+			rxe_remove(rxe);
+			return 0;
+		}
+	}
+	spin_unlock_bh(&net_info_lock);
+	pr_warning("rxe_sys: instance %s not found\n", intf);
+
+	return 0;
+}
+
+module_param_call(add, rxe_param_set_add, NULL, NULL, 0200);
+module_param_call(remove, rxe_param_set_remove, NULL, NULL, 0200);
+
+static int rxe_param_set_mtu(const char *val, struct kernel_param *kp)
+{
+	int i, rc, len;
+	int do_all = 0;
+	char intf[32];
+	char cmd[32];
+	int tmp_mtu;
+
+	len = sanitize_arg(val, intf, sizeof(intf));
+	if (!len)
+		return -EINVAL;
+
+	rc = sscanf(intf, "%s %d", cmd, &tmp_mtu);
+	if (rc != 2) {
+		pr_warning("rxe_net: mtu bogus input (%s)\n", intf);
+		goto out;
+	}
+
+	pr_info("set_mtu: %s %d\n", cmd, tmp_mtu);
+
+	if (!(is_power_of_2(tmp_mtu)
+	      && (tmp_mtu >= 256)
+	      && (tmp_mtu <= 4096))) {
+		pr_warning("rxe_net: bogus mtu (%s - %d pow2  %d)\n",
+			   intf, tmp_mtu, is_power_of_2(tmp_mtu));
+		goto out;
+	}
+
+	tmp_mtu = rxe_mtu_int_to_enum(tmp_mtu);
+
+	if (strcmp("all", cmd) == 0)
+		do_all = 1;
+
+	spin_lock_bh(&net_info_lock);
+	for (i = 0; i < RXE_MAX_IF_INDEX; i++) {
+		if (net_info[i].rxe && net_info[i].ndev) {
+			if (do_all
+			    || (0 == strncmp(cmd,
+					     net_info[i].rxe->ib_dev.name,
+					     len))) {
+				net_info[i].rxe->pref_mtu = tmp_mtu;
+
+				rxe_set_mtu(net_info[i].rxe,
+					    net_info[i].ndev->mtu, 1);
+
+				if (!do_all)
+					break;
+			}
+		}
+	}
+	spin_unlock_bh(&net_info_lock);
+
+out:
+	return 0;
+}
+
+module_param_call(mtu, rxe_param_set_mtu, NULL, NULL, 0200);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20110724201229.815123934-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org

#108 lore raw

Re: [patch v2 34/37] add rxe_net_sysfs.c

Quoted 1 line · On Sun, Jul 24, 2011 at 9:43 PM, <rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@pu…

+/* Copy argument and remove trailing CR. Return the new length. */

As far as I can see the function below removes a trailing newline instead of a trailing carriage return ?

Quoted 7 lines
drivers/infiniband/hw/rxe/rxe_net_sysfs.c new file +7 -0
+static int sanitize_arg(const char *val, char *intf, int intf_len)
+{
+	int len;
+
+	if (!val)
+		return 0;
+

drivers/infiniband/hw/rxe/rxe_net_sysfs.c line 54

Quoted 10 lines
drivers/infiniband/hw/rxe/rxe_net_sysfs.c new file +10 -0
+	/* Remove newline. */
+	for (len = 0; len < intf_len - 1 && val[len] && val[len] != '\n'; len++)
+		intf[len] = val[len];
+	intf[len] = 0;
+
+	if (len == 0 || (val[len] != 0 && val[len] != '\n'))
+		return 0;
+
+	return len;
+}

Has it been considered to use strchr() to find the first occurrence of a newline character in "val" ?

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#109 lore raw

PATCH v2 35/37 add rxe_sample.c

In reply to [email protected]

module that implements a soft IB device using ib_rxe in loopback.

---
 drivers/infiniband/hw/rxe/rxe_sample.c |  226 +++++++++++++++++++++++++++++++++
 1 file changed, 226 insertions(+)
drivers/infiniband/hw/rxe/rxe_sample.c new file +226 -0
Index: infiniband/drivers/infiniband/hw/rxe/rxe_sample.c
===================================================================
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *	- Redistributions of source code must retain the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer.
+ *
+ *	- Redistributions in binary form must reproduce the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer in the documentation and/or other materials
+ *	  provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * sample driver for IB transport over rxe
+ * implements a simple loopback device on module load
+ */
+
+#include <linux/skbuff.h>
+
+#include <linux/device.h>
+
+#include "rxe.h"
+
+MODULE_AUTHOR("Bob Pearson");
+MODULE_DESCRIPTION("RDMA transport over Converged Enhanced Ethernet");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static __be64 node_guid(struct rxe_dev *rxe)
+{
+	return cpu_to_be64(0x3333333333333333ULL);
+}
+
+static __be64 port_guid(struct rxe_dev *rxe, unsigned int port_num)
+{
+	return cpu_to_be64(0x4444444444444444ULL);
+}
+
+/*
+ * the ofed core requires that we provide a valid device
+ * object for registration
+ */
+static struct class *my_class;
+static struct device *my_dev;
+
+static struct device *dma_device(struct rxe_dev *rxe)
+{
+	return my_dev;
+}
+
+static int mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+	return 0;
+}
+
+static int mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+	return 0;
+}
+
+/* just loopback packet */
+static int send(struct rxe_dev *rxe, struct sk_buff *skb)
+{
+	struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
+
+	pkt->rxe = rxe;
+	pkt->mask = RXE_LRH_MASK;
+
+	return rxe_rcv(skb);
+}
+
+static struct sk_buff *init_packet(struct rxe_dev *rxe, struct rxe_av *av,
+				   int paylen)
+{
+	struct sk_buff *skb;
+	struct rxe_pkt_info *pkt;
+
+	paylen += RXE_LRH_BYTES;
+
+	if (av->attr.ah_flags & IB_AH_GRH)
+		paylen += RXE_GRH_BYTES;
+
+	skb = alloc_skb(paylen, GFP_ATOMIC);
+	if (!skb)
+		return NULL;
+
+	skb->dev	= NULL;
+	skb->protocol	= 0;
+
+	pkt		= SKB_TO_PKT(skb);
+	pkt->rxe	= rxe;
+	pkt->port_num	= 1;
+	pkt->hdr	= skb_put(skb, paylen);
+	pkt->mask	= RXE_LRH_MASK;
+	if (av->attr.ah_flags & IB_AH_GRH)
+		pkt->mask	|= RXE_GRH_MASK;
+
+	return skb;
+}
+
+static int init_av(struct rxe_dev *rxe, struct ib_ah_attr *attr,
+		   struct rxe_av *av)
+{
+	if (!av->attr.dlid)
+		av->attr.dlid = 1;
+	return 0;
+}
+
+static char *parent_name(struct rxe_dev *rxe, unsigned int port_num)
+{
+	return "sample";
+}
+
+static enum rdma_link_layer link_layer(struct rxe_dev *rxe,
+				       unsigned int port_num)
+{
+	return IB_LINK_LAYER_INFINIBAND;
+}
+
+static struct rxe_ifc_ops ifc_ops = {
+	.node_guid	= node_guid,
+	.port_guid	= port_guid,
+	.dma_device	= dma_device,
+	.mcast_add	= mcast_add,
+	.mcast_delete	= mcast_delete,
+	.send		= send,
+	.init_packet	= init_packet,
+	.init_av	= init_av,
+	.parent_name	= parent_name,
+	.link_layer	= link_layer,
+};
+
+static struct rxe_dev *rxe_sample;
+
+static int rxe_sample_add(void)
+{
+	int err;
+	struct rxe_port *port;
+
+	rxe_sample = (struct rxe_dev *)ib_alloc_device(sizeof(*rxe_sample));
+	if (!rxe_sample) {
+		err = -ENOMEM;
+		goto err1;
+	}
+
+	rxe_sample->ifc_ops = &ifc_ops;
+
+	err = rxe_add(rxe_sample, 4500);
+	if (err)
+		goto err2;
+
+	/* bit of a hack */
+	port = &rxe_sample->port[0];
+	port->attr.state = IB_PORT_ACTIVE;
+	port->attr.phys_state = 5;
+	port->attr.max_mtu = IB_MTU_4096;
+	port->attr.active_mtu = IB_MTU_4096;
+	port->mtu_cap = IB_MTU_4096;
+	port->attr.lid = 1;
+
+	pr_info("rxe_sample: added %s\n",
+		 rxe_sample->ib_dev.name);
+	return 0;
+
+err2:
+	ib_dealloc_device(&rxe_sample->ib_dev);
+err1:
+	return err;
+}
+
+static void rxe_sample_remove(void)
+{
+	if (!rxe_sample)
+		goto done;
+
+	rxe_remove(rxe_sample);
+
+	pr_info("rxe_sample: removed %s\n",
+		rxe_sample->ib_dev.name);
+done:
+	return;
+}
+
+static int __init rxe_sample_init(void)
+{
+	int err;
+
+	rxe_crc_disable = 1;
+
+	my_class = class_create(THIS_MODULE, "foo");
+	my_dev = device_create(my_class, NULL, 0, NULL, "bar");
+
+	err = rxe_sample_add();
+	return err;
+}
+
+static void __exit rxe_sample_exit(void)
+{
+	rxe_sample_remove();
+
+	device_destroy(my_class, my_dev->devt);
+	class_destroy(my_class);
+	return;
+}
+
+module_init(rxe_sample_init);
+module_exit(rxe_sample_exit);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20110724201229.865806162-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org

#111 lore raw

Re: [patch v2 35/37] add rxe_sample.c

Quoted 2 lines · On Sun, Jul 24, 2011 at 9:43 PM, <rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@pu…

module that implements a soft IB device using ib_rxe in loopback. +MODULE_DESCRIPTION("RDMA transport over Converged Enhanced Ethernet");

That's the same description as for the ib_rxe_net kernel module, so one of the two probably should be updated.

drivers/infiniband/hw/rxe/rxe_sample.c line 51

Quoted 6 lines
drivers/infiniband/hw/rxe/rxe_sample.c new file +6 -0
+MODULE_LICENSE("Dual BSD/GPL");
+
+static __be64 node_guid(struct rxe_dev *rxe)
+{
+	return cpu_to_be64(0x3333333333333333ULL);
+}

In the OUI part of the above EUI-64 identifier the "M" (multicast) and L ("locally administered") bits are set. I'm not sure that's fine. Also, has it been considered to use __constant_cpu_to_be64() instead of cpu_to_be64() ?

drivers/infiniband/hw/rxe/rxe_sample.c line 56

Quoted 4 lines
drivers/infiniband/hw/rxe/rxe_sample.c new file +4 -0
+static __be64 port_guid(struct rxe_dev *rxe, unsigned int port_num)
+{
+	return cpu_to_be64(0x4444444444444444ULL);
+}

Same remark here about __constant_cpu_to_be64().

drivers/infiniband/hw/rxe/rxe_sample.c line 63

Quoted 6 lines
drivers/infiniband/hw/rxe/rxe_sample.c new file +6 -0
+/*
+ * the ofed core requires that we provide a valid device
+ * object for registration
+ */
+static struct class *my_class;
+static struct device *my_dev;

Probably the above comment should be updated since this driver is being submitted for inclusion in the mainline Linux kernel ?

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (av->attr.ah_flags & IB_AH_GRH)
+		pkt->mask	|= RXE_GRH_MASK;

Please use a space instead of a tab before "|=".

drivers/infiniband/hw/rxe/rxe_sample.c line 163

Quoted 12 lines
drivers/infiniband/hw/rxe/rxe_sample.c new file +12 -0
+static struct rxe_dev *rxe_sample;
+
+static int rxe_sample_add(void)
+{
+	int err;
+	struct rxe_port *port;
+
+	rxe_sample = (struct rxe_dev *)ib_alloc_device(sizeof(*rxe_sample));
+	if (!rxe_sample) {
+		err = -ENOMEM;
+		goto err1;
+	}

Since calling rxe_sample_add() twice in a row is an error a check for that condition might be appropriate, e.g. by inserting a WARN_ON(rxe_sample) before the allocation.

drivers/infiniband/hw/rxe/rxe_sample.c line 201

Quoted 12 lines
drivers/infiniband/hw/rxe/rxe_sample.c new file +12 -0
+static void rxe_sample_remove(void)
+{
+	if (!rxe_sample)
+		goto done;
+
+	rxe_remove(rxe_sample);
+
+	pr_info("rxe_sample: removed %s\n",
+		rxe_sample->ib_dev.name);
+done:
+	return;
+}

Setting rxe_sample to NULL after the rxe_remove() call can be a help to catch potential dangling pointer dereferences.

drivers/infiniband/hw/rxe/rxe_sample.c line 214

Quoted 13 lines
drivers/infiniband/hw/rxe/rxe_sample.c new file +13 -0
+
+static int __init rxe_sample_init(void)
+{
+	int err;
+
+	rxe_crc_disable = 1;
+
+	my_class = class_create(THIS_MODULE, "foo");
+	my_dev = device_create(my_class, NULL, 0, NULL, "bar");
+
+	err = rxe_sample_add();
+	return err;
+}

Sorry, but it's not clear to me why a new class has to be created this sample driver. Also, one should be aware that class and device names are globally visible and hence should be meaningful - names like "foo" and "bar" are not acceptable.

# find /sys -name foo -o -name bar
/sys/devices/virtual/foo
/sys/devices/virtual/foo/bar
/sys/class/foo
/sys/class/foo/bar

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#112 lore raw

PATCH v2 36/37 add Makefile

In reply to [email protected]

Makefile

---
 drivers/infiniband/hw/rxe/Makefile |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/infiniband/hw/rxe/Makefile new file +30 -0
Index: infiniband/drivers/infiniband/hw/rxe/Makefile
===================================================================
@@ -0,0 +1,30 @@
+obj-$(CONFIG_INFINIBAND_RXE) += ib_rxe.o ib_rxe_net.o ib_rxe_sample.o
+
+ib_rxe-y := \
+	rxe.o \
+	rxe_comp.o \
+	rxe_req.o \
+	rxe_resp.o \
+	rxe_recv.o \
+	rxe_pool.o \
+	rxe_queue.o \
+	rxe_verbs.o \
+	rxe_av.o \
+	rxe_srq.o \
+	rxe_qp.o \
+	rxe_cq.o \
+	rxe_mr.o \
+	rxe_dma.o \
+	rxe_opcode.o \
+	rxe_mmap.o \
+	rxe_arbiter.o \
+	rxe_icrc.o \
+	rxe_mcast.o \
+	rxe_task.o
+
+ib_rxe_net-y := \
+	rxe_net.o \
+	rxe_net_sysfs.o
+
+ib_rxe_sample-y := \
+	rxe_sample.o

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#113 lore raw

PATCH v2 37/37 add Kconfig

In reply to [email protected]

Kconfig file

---
 drivers/infiniband/Kconfig        |    1 +
 drivers/infiniband/Makefile       |    1 +
 drivers/infiniband/hw/rxe/Kconfig |   28 ++++++++++++++++++++++++++++
 3 files changed, 30 insertions(+)
drivers/infiniband/Kconfig +1 -0
Index: infiniband/drivers/infiniband/Kconfig
===================================================================
@@ -51,6 +51,7 @@ source "drivers/infiniband/hw/cxgb3/Kcon
 source "drivers/infiniband/hw/cxgb4/Kconfig"
 source "drivers/infiniband/hw/mlx4/Kconfig"
 source "drivers/infiniband/hw/nes/Kconfig"
+source "drivers/infiniband/hw/rxe/Kconfig"
 
 source "drivers/infiniband/ulp/ipoib/Kconfig"
 
drivers/infiniband/Makefile +1 -0
Index: infiniband/drivers/infiniband/Makefile
===================================================================
@@ -8,6 +8,7 @@ obj-$(CONFIG_INFINIBAND_CXGB3)		+= hw/cx
 obj-$(CONFIG_INFINIBAND_CXGB4)		+= hw/cxgb4/
 obj-$(CONFIG_MLX4_INFINIBAND)		+= hw/mlx4/
 obj-$(CONFIG_INFINIBAND_NES)		+= hw/nes/
+obj-$(CONFIG_INFINIBAND_RXE)		+= hw/rxe/
 obj-$(CONFIG_INFINIBAND_IPOIB)		+= ulp/ipoib/
 obj-$(CONFIG_INFINIBAND_SRP)		+= ulp/srp/
 obj-$(CONFIG_INFINIBAND_ISER)		+= ulp/iser/
drivers/infiniband/hw/rxe/Kconfig new file +28 -0
Index: infiniband/drivers/infiniband/hw/rxe/Kconfig
===================================================================
@@ -0,0 +1,28 @@
+config INFINIBAND_RXE
+	tristate "Software RDMA over Ethernet (RoCE) driver"
+	depends on INET && PCI && INFINIBAND
+	---help---
+	This driver implements the InfiniBand RDMA transport over
+	the Linux network stack. It enables a system with a
+	standard Ethernet adapter to interoperate with a RoCE
+	adapter or with another system running the RXE driver.
+	Documentation on InfiniBand and RoCE can be downloaded at
+	www.infinibandta.org and www.openfabrics.org. (See also
+	siw which is a similar software driver for iWARP.)
+
+	The driver is split into two layers, one interfaces with the
+	Linux RDMA stack and implements a kernel or user space
+	verbs API. The user space verbs API requires a support
+	library named librxe which is loaded by the generic user
+	space verbs API, libibverbs. The other layer interfaces
+	with the Linux network stack at layer 3.
+
+	There are three kernel modules provided with RXE.
+
+	ib_rxe		- attaches to the Linux RDMA stack
+	ib_rxe_net	- attaches to the Linux network stack
+	ib_rxe_sample	- provides a simple sample network layer
+			  driver that provides a loopback interface.
+
+	Rxe_cfg provided with librxe is a configuration tool that
+	loads and unloads the ib_rxe and ib_rxe_net kernel modules

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20110724201229.966262587-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org

#115 lore raw

Re: [patch v2 37/37] add Kconfig

On Sun, Jul 24, 2011 at 9:43 PM, <[email protected]> wrote:
+config INFINIBAND_RXE
+ tristate "Software RDMA over Ethernet (RoCE) driver"
+ depends on INET && PCI && INFINIBAND
+ ---help---
+ This driver implements the InfiniBand RDMA transport over
+ the Linux network stack. It enables a system with a

Shouldn't that read "an Ethernet network" instead of "the Linux network stack" ?

+ standard Ethernet adapter to interoperate with a RoCE
+ adapter or with another system running the RXE driver.
+ Documentation on InfiniBand and RoCE can be downloaded at
+ www.infinibandta.org and www.openfabrics.org. (See also
+ siw which is a similar software driver for iWARP.)

Isn't RoCE an official IBTA standard ? If so, seems like a good idea to me to mention that here.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAO+b5-oFKiAhTkCntAo5_mMCtdg1vb1eM_mTi-8E-T_atHa_3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#117 lore raw

RE: [patch v2 37/37] add Kconfig

Quoted 18 lines

-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Bart Van Assche
Sent: Friday, August 05, 2011 1:44 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [patch v2 37/37] add Kconfig

On Sun, Jul 24, 2011 at 9:43 PM, <[email protected]> wrote:

drivers/infiniband/hw/rxe/Kconfig new file +6 -0
+config INFINIBAND_RXE
+	tristate "Software RDMA over Ethernet (RoCE) driver"
+	depends on INET && PCI && INFINIBAND
+	---help---
+	This driver implements the InfiniBand RDMA transport over
+	the Linux network stack. It enables a system with a
Quoted 2 lines

Shouldn't that read "an Ethernet network" instead of "the Linux network stack" ?

Technically it will run over more than just Ethernet. RXE plugs in at the same place as IP on top of the netdev core.
There are some assumptions about the size of the L2 address that make it work better on Ethernet but I used to run it over the loopback device and it also runs over VLANs.

Quoted 9 lines
drivers/infiniband/hw/rxe/Kconfig new file +5 -0
+	standard Ethernet adapter to interoperate with a RoCE
+	adapter or with another system running the RXE driver.
+	Documentation on InfiniBand and RoCE can be downloaded at
+	www.infinibandta.org and www.openfabrics.org. (See also
+	siw which is a similar software driver for iWARP.)

Isn't RoCE an official IBTA standard ? If so, seems like a good idea to me to mention that here.

I'll do that for v3.

Quoted 6 lines

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#118 lore raw

Re: [patch v2 37/37] add Kconfig

Quoted 16 lines · Bob Pearson
Quoted 16 lines

-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Bart Van Assche
Sent: Friday, August 05, 2011 1:44 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [patch v2 37/37] add Kconfig

On Sun, Jul 24, 2011 at 9:43 PM,  <[email protected]> wrote:
+config INFINIBAND_RXE
+     tristate "Software RDMA over Ethernet (RoCE) driver"
+     depends on INET && PCI && INFINIBAND
+     ---help---
+     This driver implements the InfiniBand RDMA transport over
+     the Linux network stack. It enables a system with a

Quoted 8 lines
Quoted 2 lines

Shouldn't that read "an Ethernet network" instead of "the Linux network stack" ?

Technically it will run over more than just Ethernet. RXE plugs in at the same place as IP on top of the netdev core.
There are some assumptions about the size of the L2 address that make it work better on Ethernet but I used to run it over the loopback device and it also runs over VLANs.

In that case I propose to change "Linux network stack" into "Linux network driver" - that's all what the rxe driver uses from the network stack, and there is more in the Linux network stack than only the network drivers.

Quoted 10 lines
Quoted 8 lines

+     standard Ethernet adapter to interoperate with a RoCE
+     adapter or with another system running the RXE driver.
+     Documentation on InfiniBand and RoCE can be downloaded at
+     www.infinibandta.org and www.openfabrics.org. (See also
+     siw which is a similar software driver for iWARP.)

Isn't RoCE an official IBTA standard ? If so, seems like a good idea to me to mention that here.

I'll do that for v3.

Thanks. Maybe it's a good idea to mention also that while RoCE benefits from a lossless converged Ethernet network, that the protocol also works over a regular (not lossless) Ethernet network.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20110724194300.421253331-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5@public.gmane.org

#120 lore raw

Hi Bob,

Am 24.07.2011 21:43, schrieb rpearson-klaOcWyJdxkshyMvu7JE4pqQE7yCjDx5-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org:

Quoted 18 lines

Changes in v2 include:

- Updated to Roland's tree as of 7/24/2011

- Moved the crc32 algorithm into a patch (slice-by-8-for_crc32.c.diff) that goes into the mainline kernel. It has been submitted upstream but is also included in here since it is required to build the driver.

- renamed rxe_sb8.c rxe_icrc.c since that is all it now does.

- Cleaned up warnings from checkpatch, C=2 and __CHECK_ENDIAN__.

- moved small .h files into rxe_loc.h

- rewrote the Kconfig text to be a little friendlier

- Changed the patch names to make them easier to handle.

Quoted 8 lines

- the quilt patch series is online at:
http://support.systemfabricworks.com/downloads/rxe/patches-v2.tgz

- librxe is online at:
http://support.systemfabricworks.com/downloads/rxe/librxe-1.0.0.tar.gz

Thanks to Roland Dreier, Bart van Assche and David Dillow for helpful suggestions.

I'm wondering what the status of this patchset is?

It would be very good if the rxe modules could be
included in the mainline kernel.

Hopefully Samba will get support for SMB-Direct (SMB2 over RDMA) support in future. And having RDMA support without hardware support would be very good for testing and also for usage on the client side against a server which has hardware RDMA support.

Are there git repositories yet (for the kernel and userspace)?

metze