new file mode 100644
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017 Mellanox Technologies Ltd. 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.
+ */
+
+#if !defined(IB_IPOIB_ACCEL_OPS_H)
+#define IB_IPOIB_ACCEL_OPS_H
+
+#include <rdma/ib_verbs.h>
+
+struct ipoib_ah;
+
+struct ib_ipoib_accel_ops {
+
+ /*
+ * HW provider driver creates the net_device for IPoIB.
+ * hca: The current ib device.
+ * name: is the format of the new network device (probably ib%d)
+ */
+ struct net_device * (*create_netdev)(struct ib_device *hca,
+ const char *name,
+ void (*setup)(struct net_device *));
+
+ /* IB resource allocation function, returns new UD QP */
+ int (*ib_dev_init)(struct net_device *dev, int *qp_num);
+ void (*ib_dev_cleanup)(struct net_device *dev);
+
+ /* handle network stack when open/stop device */
+ int (*ib_dev_open)(struct net_device *dev);
+ int (*ib_dev_stop)(struct net_device *dev);
+
+ /* send packet */
+ void (*send)(struct net_device *dev, struct sk_buff *skb,
+ struct ipoib_ah *address, u32 dqpn, u32 dqkey);
+
+ /* multicast */
+ int (*attach_mcast)(struct net_device *dev, union ib_gid *gid,
+ u16 lid, int set_qkey);
+ int (*detach_mcast)(struct net_device *dev, union ib_gid *gid,
+ u16 lid);
+
+};
+
+#endif /* IB_IPOIB_ACCEL_OPS_H */
@@ -2147,6 +2147,7 @@ struct ib_device {
struct ib_wq_attr *attr,
u32 wq_attr_mask,
struct ib_udata *udata);
+ struct ib_ipoib_accel_ops * (*get_ipoib_accel_ops)(struct ib_device *device);
struct ib_rwq_ind_table * (*create_rwq_ind_table)(struct ib_device *device,
struct ib_rwq_ind_table_init_attr *init_attr,
struct ib_udata *udata);
@@ -2322,6 +2323,14 @@ static inline u8 rdma_start_port(const struct ib_device *device)
return rdma_cap_ib_switch(device) ? 0 : 1;
}
+static inline struct ib_ipoib_accel_ops *ib_get_ipoib_accel_ops(struct ib_device *device)
+{
+ if (!device->get_ipoib_accel_ops)
+ return NULL;
+
+ return device->get_ipoib_accel_ops(device);
+}
+
/**
* rdma_end_port - Return the last valid port number for the device
* specified
The idea is to allow vendors to optimize IPoIB data path. The new structure exposes set of callback functions for handling data path flows in IPoIB driver. Each vendor can support these set of functions in order to optimize its specific data path, and let IPoIB to leverage its data path. The code of IPoIB driver was changed accordingly, and works in both ways with vendor specific implementation and without. There is an assumption, that vendors should give the full set of functions and not only part of them, in order to work properly. Signed-off-by: Erez Shitrit <erezsh@mellanox.com> --- include/rdma/ib_ipoib_accel_ops.h | 71 +++++++++++++++++++++++++++++++++++++++ include/rdma/ib_verbs.h | 9 +++++ 2 files changed, 80 insertions(+) create mode 100644 include/rdma/ib_ipoib_accel_ops.h