Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp406847lqh; Tue, 7 May 2024 02:54:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWLKaRYneiccg7/2DHE230/yx6QgtUj373BoV/Lk/yVomCrxBc8p0EUpLrD/aT1Qfr9HuMkaUYq4j8lzXh2wk99ftWsCSLJQhO5HvSAg== X-Google-Smtp-Source: AGHT+IH/K3SyYxwrR2/MKPlsu+mKs5XJKeAJp3V4gZZpsA2Gu71Wu9sncZ+X0FYOGiZezc9Fc9M6 X-Received: by 2002:a17:906:bcef:b0:a59:a3cb:8c8b with SMTP id op15-20020a170906bcef00b00a59a3cb8c8bmr5825024ejb.11.1715075659647; Tue, 07 May 2024 02:54:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715075659; cv=pass; d=google.com; s=arc-20160816; b=tQy67DKWE/Vb1hAEujUTed9WzoYoXPbMn8HDBWgYTX6EpsDnXGT5uFlVYhFUkKPeoG yLWuQRocym1PRDZknL21+Q1zbiAB7bcg8VQvdY2eSnbuioD0hzv/mqwGauGZfCk/kUep erQHTeKTL/RAaN1VuMjqCdpFpzB7tQaghIH467PgFNatbwF2OHozHmuI5hZftEp0/zJu H6/19WxNut2G+Ef/xlFsZ47vUuPoIvbuOVxqTHJJ88BDBZKl3vWby3IzMXioj0xBhBA7 PSmjpBDBhiuI7Irt5ExomAMa0in8/hRBxLwEK6asRrtMirEKMQ2/ol4+DnlicR4ZsaoO AwkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=6cDFGREVj/+/FKPys8Z2I4DttGj2j6tW05XiRyEcBbg=; fh=ujksmUrBEjpGhQjWbrjZMx9PDXUXbYR/j4y8MAq1x1o=; b=y0sFfpSYIC3+Xvgk4qmrM9JZNzIYuJUCdQRV6T45wbUOj+6bvKpyGO95/hst3V14wU Oq05LlYskRQNrxwULNZQYZxz/S1kbNF/p8nG5KI5oIS//BbVMd5uY3rZUaDu1Cyg1Ftm xoyiO2JAZts8xfmH76RXQJps6W/hGgtOEPlo0Tgn5Kq06kimLokSFRxrAa/0UgHSwSjc A/en9jC+zXo0O9qA1fUy9K+1fzbXWfrWiUcqDF138KjAS9/SXlynUxs9cg/wRqMA0/lN LAqd0gNaplsIr+y1+RHSJSqD88aswCNllWqNItoIBa13x9tlPTv1/L8HBP+aWcTkK54l JDHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mEeKrAF3; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-171034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u5-20020a170906c40500b00a59bacc9cebsi3276511ejz.591.2024.05.07.02.54.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:54:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mEeKrAF3; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-171034-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8C9171F23266 for ; Tue, 7 May 2024 09:53:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8C6A14EC4D; Tue, 7 May 2024 09:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="mEeKrAF3" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E07114D714; Tue, 7 May 2024 09:53:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715075609; cv=none; b=giKzW4xj90vukoVxA9HoSekTu5AyR7wnkswafakTis1O6Eaw6zMsp/l9+o4r9/QrucT6RvSvnZgyKg46m+2wN3A1VtI686BKchXtSMgdTt+KHvht4FnKcvf+r0JRYnc0Zxyrv6tApAxNpfa8CgSHJU9E5F35UwVXYtGDqK/hAjI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715075609; c=relaxed/simple; bh=aATkdZwAVIo+8tSFMb3c+jbnvPRsopOiumaKJVmkTx0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=GTqf+H0+HIBUWQwgv4wxVClNPJVFXOAA6ONmE8ldhD+Xsn0ZgT3znnh9jx6wtB1s63scrw61GNJsTFOTgyOE+JczZVTnFlB8zc958Cu9v5t5sDp9z8hNEKNusZ6TEboSIL7PzNz6xqH5Cz04viKrc4bpl68z1SF1BmieXG+LGgc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=mEeKrAF3; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 152DF20B2C87; Tue, 7 May 2024 02:53:21 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 152DF20B2C87 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1715075601; bh=6cDFGREVj/+/FKPys8Z2I4DttGj2j6tW05XiRyEcBbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mEeKrAF3sucvuxY+Kx18L91z+faPDJHLArVHuF+6JRLit0GELI+s/nJp9TbeLGNqG t77ze5dtOc4T0LwE+z0z7zZovRy+ikDuznQQRSdMQaUug9gmaYbXIDyEnW8gihZXRi zZls66ROVJsHlRQHMPwaLqk5wbGpZ53c31kio32E= From: Konstantin Taranov To: kotaranov@microsoft.com, sharmaajay@microsoft.com, longli@microsoft.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH rdma-next 3/3] RDMA/mana_ib: Modify QP state Date: Tue, 7 May 2024 02:53:15 -0700 Message-Id: <1715075595-24470-4-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1715075595-24470-1-git-send-email-kotaranov@linux.microsoft.com> References: <1715075595-24470-1-git-send-email-kotaranov@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Konstantin Taranov Implement modify QP state for RC QPs. Signed-off-by: Konstantin Taranov --- drivers/infiniband/hw/mana/mana_ib.h | 37 ++++++++++++++ drivers/infiniband/hw/mana/qp.c | 72 +++++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h index 5cccbe3..d29dee7 100644 --- a/drivers/infiniband/hw/mana/mana_ib.h +++ b/drivers/infiniband/hw/mana/mana_ib.h @@ -140,6 +140,7 @@ enum mana_ib_command_code { MANA_IB_DESTROY_CQ = 0x30009, MANA_IB_CREATE_RC_QP = 0x3000a, MANA_IB_DESTROY_RC_QP = 0x3000b, + MANA_IB_SET_QP_STATE = 0x3000d, }; struct mana_ib_query_adapter_caps_req { @@ -286,6 +287,42 @@ struct mana_rnic_destroy_rc_qp_resp { struct gdma_resp_hdr hdr; }; /* HW Data */ +struct mana_ib_ah_attr { + u8 src_addr[16]; + u8 dest_addr[16]; + u8 src_mac[ETH_ALEN]; + u8 dest_mac[ETH_ALEN]; + u8 src_addr_type; + u8 dest_addr_type; + u8 hop_limit; + u8 traffic_class; + u16 src_port; + u16 dest_port; + u32 reserved; +}; + +struct mana_rnic_set_qp_state_req { + struct gdma_req_hdr hdr; + mana_handle_t adapter; + mana_handle_t qp_handle; + u64 attr_mask; + u32 qp_state; + u32 path_mtu; + u32 rq_psn; + u32 sq_psn; + u32 dest_qpn; + u32 max_dest_rd_atomic; + u32 retry_cnt; + u32 rnr_retry; + u32 min_rnr_timer; + u32 reserved; + struct mana_ib_ah_attr ah_attr; +}; /* HW Data */ + +struct mana_rnic_set_qp_state_resp { + struct gdma_resp_hdr hdr; +}; /* HW Data */ + static inline struct gdma_context *mdev_to_gc(struct mana_ib_dev *mdev) { return mdev->gdma_dev->gdma_context; diff --git a/drivers/infiniband/hw/mana/qp.c b/drivers/infiniband/hw/mana/qp.c index 14e6adb..5393b6f 100644 --- a/drivers/infiniband/hw/mana/qp.c +++ b/drivers/infiniband/hw/mana/qp.c @@ -492,11 +492,79 @@ int mana_ib_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr, return -EINVAL; } +static int mana_ib_gd_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, + int attr_mask, struct ib_udata *udata) +{ + struct mana_ib_dev *mdev = container_of(ibqp->device, struct mana_ib_dev, ib_dev); + struct mana_ib_qp *qp = container_of(ibqp, struct mana_ib_qp, ibqp); + struct mana_rnic_set_qp_state_resp resp = {}; + struct mana_rnic_set_qp_state_req req = {}; + struct gdma_context *gc = mdev_to_gc(mdev); + struct mana_port_context *mpc; + struct net_device *ndev; + int err; + + mana_gd_init_req_hdr(&req.hdr, MANA_IB_SET_QP_STATE, sizeof(req), sizeof(resp)); + req.hdr.dev_id = gc->mana_ib.dev_id; + req.adapter = mdev->adapter_handle; + req.qp_handle = qp->qp_handle; + req.qp_state = attr->qp_state; + req.attr_mask = attr_mask; + req.path_mtu = attr->path_mtu; + req.rq_psn = attr->rq_psn; + req.sq_psn = attr->sq_psn; + req.dest_qpn = attr->dest_qp_num; + req.max_dest_rd_atomic = attr->max_dest_rd_atomic; + req.retry_cnt = attr->retry_cnt; + req.rnr_retry = attr->rnr_retry; + req.min_rnr_timer = attr->min_rnr_timer; + if (attr_mask & IB_QP_AV) { + ndev = mana_ib_get_netdev(&mdev->ib_dev, ibqp->port); + if (!ndev) { + ibdev_dbg(&mdev->ib_dev, "Invalid port %u in RC QP %u\n", + ibqp->port, ibqp->qp_num); + return -EINVAL; + } + mpc = netdev_priv(ndev); + copy_in_reverse(req.ah_attr.src_mac, mpc->mac_addr, ETH_ALEN); + copy_in_reverse(req.ah_attr.dest_mac, attr->ah_attr.roce.dmac, ETH_ALEN); + copy_in_reverse(req.ah_attr.src_addr, attr->ah_attr.grh.sgid_attr->gid.raw, + sizeof(union ib_gid)); + copy_in_reverse(req.ah_attr.dest_addr, attr->ah_attr.grh.dgid.raw, + sizeof(union ib_gid)); + if (rdma_gid_attr_network_type(attr->ah_attr.grh.sgid_attr) == RDMA_NETWORK_IPV4) { + req.ah_attr.src_addr_type = SGID_TYPE_IPV4; + req.ah_attr.dest_addr_type = SGID_TYPE_IPV4; + } else { + req.ah_attr.src_addr_type = SGID_TYPE_IPV6; + req.ah_attr.dest_addr_type = SGID_TYPE_IPV6; + } + req.ah_attr.dest_port = ROCE_V2_UDP_DPORT; + req.ah_attr.src_port = rdma_get_udp_sport(attr->ah_attr.grh.flow_label, + ibqp->qp_num, attr->dest_qp_num); + req.ah_attr.traffic_class = attr->ah_attr.grh.traffic_class; + req.ah_attr.hop_limit = attr->ah_attr.grh.hop_limit; + } + + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); + if (err) { + ibdev_err(&mdev->ib_dev, "Failed modify qp err %d", err); + return err; + } + + return 0; +} + int mana_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, struct ib_udata *udata) { - /* modify_qp is not supported by this version of the driver */ - return -EOPNOTSUPP; + switch (ibqp->qp_type) { + case IB_QPT_RC: + return mana_ib_gd_modify_qp(ibqp, attr, attr_mask, udata); + default: + ibdev_dbg(ibqp->device, "Modify QP type %u not supported", ibqp->qp_type); + return -EOPNOTSUPP; + } } static int mana_ib_destroy_qp_rss(struct mana_ib_qp *qp, -- 2.43.0