From patchwork Fri Dec 20 20:38:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Upinder Malhi (umalhi)" X-Patchwork-Id: 3391871 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70589C0D4A for ; Fri, 20 Dec 2013 20:39:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8819F20703 for ; Fri, 20 Dec 2013 20:39:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 959E5206F3 for ; Fri, 20 Dec 2013 20:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750817Ab3LTUjP (ORCPT ); Fri, 20 Dec 2013 15:39:15 -0500 Received: from mtv-iport-4.cisco.com ([173.36.130.15]:59425 "EHLO mtv-iport-4.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752429Ab3LTUjN (ORCPT ); Fri, 20 Dec 2013 15:39:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=4970; q=dns/txt; s=iport; t=1387571953; x=1388781553; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=NAiIJq/sqJ0Rwc/NfdW78X8M0ryRNUDsUuYGruCWNSg=; b=WCPjljocVkvdgcTIuUywUUGHw2NOsS2/rl8bwSg/HNYln75HKWku8vcb rOlk91Ux4OrcHXTXu8WVq0Uu/cGCogh+Azq3R0vVj1jJ+vXg10ObIssqY mux705Xx4UX3gBb5bP590g+2qe0QzCX0M1WfNPwxIN4aEjYrNSx16hPFC g=; X-IronPort-AV: E=Sophos;i="4.95,523,1384300800"; d="scan'208";a="101057873" Received: from mtv-core-1.cisco.com ([171.68.58.6]) by mtv-iport-4.cisco.com with ESMTP; 20 Dec 2013 20:39:11 +0000 Received: from sjc-savbu-bld03.cisco.com (sjc-savbu-bld03.cisco.com [171.71.188.58]) by mtv-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id rBKKdArK001089; Fri, 20 Dec 2013 20:39:11 GMT Received: by sjc-savbu-bld03.cisco.com (Postfix, from userid 246720) id DD5763F809; Fri, 20 Dec 2013 12:39:10 -0800 (PST) From: Upinder Malhi To: linux-rdma@vger.kernel.org, roland@kernel.org Cc: Upinder Malhi Subject: [PATCH for-next 5/6] IB/usnic: Add UDP support in usnic_ib_qp_grp.[hc] Date: Fri, 20 Dec 2013 12:38:22 -0800 Message-Id: <1387571903-9398-6-git-send-email-umalhi@cisco.com> X-Mailer: git-send-email 1.8.0-rc0 In-Reply-To: <1387571903-9398-1-git-send-email-umalhi@cisco.com> References: <1387571903-9398-1-git-send-email-umalhi@cisco.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-15.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP UDP support for qp_grps/qps. Signed-off-by: Upinder Malhi --- drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | 88 +++++++++++++++++++++++++++ drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h | 11 ++++ 2 files changed, 99 insertions(+) -- 1.8.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c index bf3a2aa..71efb8d 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c @@ -246,6 +246,80 @@ static void release_roce_custom_flow(struct usnic_ib_qp_grp_flow *qp_flow) } static struct usnic_ib_qp_grp_flow* +create_udp_flow(struct usnic_ib_qp_grp *qp_grp, + struct usnic_transport_spec *trans_spec) +{ + struct socket *sock; + int sock_fd; + int err; + struct filter filter; + struct usnic_filter_action uaction; + struct usnic_ib_qp_grp_flow *qp_flow; + struct usnic_fwd_flow *flow; + enum usnic_transport_type trans_type; + uint32_t addr; + uint16_t port_num; + int proto; + + trans_type = trans_spec->trans_type; + sock_fd = trans_spec->udp.sock_fd; + + /* Get and check socket */ + sock = usnic_transport_get_socket(sock_fd); + if (IS_ERR_OR_NULL(sock)) + return ERR_CAST(sock); + + err = usnic_transport_sock_get_addr(sock, &proto, &addr, &port_num); + if (err) + goto out_put_sock; + + if (proto != IPPROTO_UDP) { + usnic_err("Protocol for fd %d is not UDP", sock_fd); + err = -EPERM; + goto out_put_sock; + } + + /* Create flow */ + usnic_fwd_init_udp_filter(&filter, addr, port_num); + err = init_filter_action(qp_grp, &uaction); + if (err) + goto out_put_sock; + + flow = usnic_fwd_alloc_flow(qp_grp->ufdev, &filter, &uaction); + if (IS_ERR_OR_NULL(flow)) { + usnic_err("Unable to alloc flow failed with err %ld\n", + PTR_ERR(flow)); + err = (flow) ? PTR_ERR(flow) : -EFAULT; + goto out_put_sock; + } + + /* Create qp_flow */ + qp_flow = kzalloc(sizeof(*qp_flow), GFP_ATOMIC); + if (IS_ERR_OR_NULL(qp_flow)) { + err = (qp_flow) ? PTR_ERR(qp_flow) : -ENOMEM; + goto out_dealloc_flow; + } + qp_flow->flow = flow; + qp_flow->trans_type = trans_type; + qp_flow->udp.sock = sock; + qp_flow->qp_grp = qp_grp; + return qp_flow; + +out_dealloc_flow: + usnic_fwd_dealloc_flow(flow); +out_put_sock: + usnic_transport_put_socket(sock); + return ERR_PTR(err); +} + +static void release_udp_flow(struct usnic_ib_qp_grp_flow *qp_flow) +{ + usnic_fwd_dealloc_flow(qp_flow->flow); + usnic_transport_put_socket(qp_flow->udp.sock); + kfree(qp_flow); +} + +static struct usnic_ib_qp_grp_flow* create_and_add_flow(struct usnic_ib_qp_grp *qp_grp, struct usnic_transport_spec *trans_spec) { @@ -257,6 +331,9 @@ create_and_add_flow(struct usnic_ib_qp_grp *qp_grp, case USNIC_TRANSPORT_ROCE_CUSTOM: qp_flow = create_roce_custom_flow(qp_grp, trans_spec); break; + case USNIC_TRANSPORT_IPV4_UDP: + qp_flow = create_udp_flow(qp_grp, trans_spec); + break; default: usnic_err("Unsupported transport %u\n", trans_spec->trans_type); @@ -278,6 +355,9 @@ static void release_and_remove_flow(struct usnic_ib_qp_grp_flow *qp_flow) case USNIC_TRANSPORT_ROCE_CUSTOM: release_roce_custom_flow(qp_flow); break; + case USNIC_TRANSPORT_IPV4_UDP: + release_udp_flow(qp_flow); + break; default: WARN(1, "Unsupported transport %u\n", qp_flow->trans_type); @@ -544,11 +624,19 @@ static int qp_grp_id_from_flow(struct usnic_ib_qp_grp_flow *qp_flow, uint32_t *id) { enum usnic_transport_type trans_type = qp_flow->trans_type; + int err; switch (trans_type) { case USNIC_TRANSPORT_ROCE_CUSTOM: *id = qp_flow->usnic_roce.port_num; break; + case USNIC_TRANSPORT_IPV4_UDP: + err = usnic_transport_sock_get_addr(qp_flow->udp.sock, + NULL, NULL, + (uint16_t *) id); + if (err) + return err; + break; default: usnic_err("Unsupported transport %u\n", trans_type); return -EINVAL; diff --git a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h index 570fea2..a8ba1b9 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h +++ b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.h @@ -56,6 +56,9 @@ struct usnic_ib_qp_grp_flow { struct { uint16_t port_num; } usnic_roce; + struct { + struct socket *sock; + } udp; }; struct usnic_ib_qp_grp *qp_grp; struct list_head link; @@ -76,6 +79,14 @@ usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = { {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,}, }, }, + { /*USNIC_TRANSPORT_IPV4_UDP*/ + .resources = { + {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,}, + {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,}, + {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,}, + {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,}, + }, + }, }; const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);