From patchwork Wed Mar 1 14:02:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erez Shitrit X-Patchwork-Id: 9598453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7FFA60453 for ; Wed, 1 Mar 2017 14:05:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 965F128541 for ; Wed, 1 Mar 2017 14:05:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B15628560; Wed, 1 Mar 2017 14:05:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F2BD28541 for ; Wed, 1 Mar 2017 14:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751470AbdCAOFH (ORCPT ); Wed, 1 Mar 2017 09:05:07 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:33362 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751037AbdCAOEf (ORCPT ); Wed, 1 Mar 2017 09:04:35 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from erezsh@mellanox.com) with ESMTPS (AES256-SHA encrypted); 1 Mar 2017 16:02:47 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v21E2kkA028329; Wed, 1 Mar 2017 16:02:47 +0200 From: Erez Shitrit To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, valex@mellanox.com, leonro@mellanox.com, Erez Shitrit Subject: [RFC for accelerated IPoIB 04/26] IB/verb: Add ipoib_options struct and API Date: Wed, 1 Mar 2017 16:02:12 +0200 Message-Id: <1488376954-8346-5-git-send-email-erezsh@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1488376954-8346-1-git-send-email-erezsh@mellanox.com> References: <1488376954-8346-1-git-send-email-erezsh@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 diff --git a/include/rdma/ib_ipoib_accel_ops.h b/include/rdma/ib_ipoib_accel_ops.h new file mode 100644 index 000000000000..e2b177f01ab5 --- /dev/null +++ b/include/rdma/ib_ipoib_accel_ops.h @@ -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 + +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 */ diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 89f5bd4e1d52..68e3bf25450d 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.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