From nobody Fri Sep 22 21:57:29 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RsmMs6pnmz4tTvX; Fri, 22 Sep 2023 21:57:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RsmMs5Zjpz3THw; Fri, 22 Sep 2023 21:57:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695419849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6xwE6hykhhw3YFyEitv122LsCFRFL0GKyIebadkm8f8=; b=CVrXwGQhEvhNK4c5hhhaQ82XYsyGaZySDH6acFukvbb51k+Wa+Itbf7RwWaDmmTEJJ8Dc8 dJL7QPeeeOoMpF7VUnkIwDGEBI8kuuVjKyZ/XrXX+RmP2Xfc7iv/lT0NnJu1WyHnawzVkE F4kH9BDHpmdY9orbJXpsHkm8sQBpPNpUuc6KMbq792abhz6HcwC38xhuOLRVJ1hVCgXzgX xXqihXfeS+GAhq/BTG70KHfL4pP/BtYzBDJIVVZhbT5E2yR3eCYsOkwSfmxqaOZfCIwE9W z5OHxSVU4x7OSgfmm5utFMYGnjp8XRX9q0veCr/pdT214HVX3nhFXAEpRUYVmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695419849; a=rsa-sha256; cv=none; b=N2UROR/WiXAAIwGeUTwGg5I78mQE95S8qis/9azqfEd4uuB2raG9bzuzxxgXnk1t1AcDXp ACZCkrNGvTRoKLqXLd5ejB25yf3yg6+EH9sF9/VHeQR2P1dOEKVcQrpVCoDEqsADRVIZmU eskY8nFzeWorawe/eVAxDs/yHrn5aeRwrGZWjBbvIXkQbgtVSHwIiNPHYTAj7F8GqSycEq HMSnAWbVAjTklNMycrV9jEKU2i0biMS5QWKMWlKIU46mNnurf+iaC2czM5/bDmXyxF+R8q V7qJu6cr36geIjKiCTEJgCB+LUp2AWRJTaRmk1rmxxMuABSw1SKfYYPgVa5HGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695419849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6xwE6hykhhw3YFyEitv122LsCFRFL0GKyIebadkm8f8=; b=lTGGw62BteJ3mtqWS5v6B757vUP1zpmPEx0wkORLlpbP3TjVE8TjhUEA7aSj4e9bNW8C5b IoWr400V9DLx+RW09tuGRcUTdhMsadbt9gyqfa5rFfNcNTbu4xwQVULzxdPP1DA1lYhQul 2j1RR+pm7GW8KgnY0tYwHB4sPHZ/yBFGcwkrpkLaOHPZR/LsVL3d1AmhdKayxcQGj1qAjI PTVFz8cBD1X5YawyTk06LVfeH59r+7ppJ8gWmmZywVSxQf34R9h02PFCs0vYFXAS7phxGG NYNhQizMvUlZO3YBqAY3oqUBSgQ6QTbW55JG14mZnCsozeYaRCepb6hEEst1QQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RsmMs3hLYzf1d; Fri, 22 Sep 2023 21:57:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38MLvTY3047853; Fri, 22 Sep 2023 21:57:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38MLvTBv047850; Fri, 22 Sep 2023 21:57:29 GMT (envelope-from git) Date: Fri, 22 Sep 2023 21:57:29 GMT Message-Id: <202309222157.38MLvTBv047850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eric Joyner Subject: git: e3b352597e4b - stable/13 - irdma(4): use related vnet for searching netdev List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: erj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e3b352597e4bcb4ec94cb95db23c041da7f7e61c Auto-Submitted: auto-generated The branch stable/13 has been updated by erj: URL: https://cgit.FreeBSD.org/src/commit/?id=e3b352597e4bcb4ec94cb95db23c041da7f7e61c commit e3b352597e4bcb4ec94cb95db23c041da7f7e61c Author: Bartosz Sobczak AuthorDate: 2023-08-21 11:56:57 +0000 Commit: Eric Joyner CommitDate: 2023-09-22 21:55:18 +0000 irdma(4): use related vnet for searching netdev It was found through testing that when ULP uses individual vnet, the search for the correct vlan_id may failing because of no proper interface with given address. The solution is to use vnet associated to the connection whenever possible. Signed-off-by: Bartosz Sobczak Signed-off-by: Eric Joyner Reviewed by: erj@ Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D41592 (cherry picked from commit bc3a013ccd23c50bb48f17211ffc36fe85d11e18) --- sys/dev/irdma/fbsd_kcompat.c | 6 ++---- sys/dev/irdma/fbsd_kcompat.h | 15 +++++++++++++++ sys/dev/irdma/irdma_cm.c | 35 ++++++++++++++++++++++++----------- sys/dev/irdma/irdma_main.h | 5 +++-- sys/dev/irdma/irdma_verbs.c | 4 ++-- 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/sys/dev/irdma/fbsd_kcompat.c b/sys/dev/irdma/fbsd_kcompat.c index 5c11f7a35544..19c3943b5151 100644 --- a/sys/dev/irdma/fbsd_kcompat.c +++ b/sys/dev/irdma/fbsd_kcompat.c @@ -391,8 +391,7 @@ irdma_get_dst_mac(struct irdma_cm_node *cm_node, struct sockaddr *dst_sin, u8 *d { struct ifnet *netdev = cm_node->iwdev->netdev; #ifdef VIMAGE - struct rdma_cm_id *rdma_id = (struct rdma_cm_id *)cm_node->cm_id->context; - struct vnet *vnet = rdma_id->route.addr.dev_addr.net; + struct vnet *vnet = irdma_cmid_to_vnet(cm_node->cm_id); #endif struct ifnet *ifp; struct llentry *lle; @@ -490,8 +489,7 @@ irdma_resolve_neigh_lpb_chk(struct irdma_device *iwdev, struct irdma_cm_node *cm struct irdma_cm_info *cm_info) { #ifdef VIMAGE - struct rdma_cm_id *rdma_id = (struct rdma_cm_id *)cm_node->cm_id->context; - struct vnet *vnet = rdma_id->route.addr.dev_addr.net; + struct vnet *vnet = irdma_cmid_to_vnet(cm_node->cm_id); #endif int arpindex; int oldarpindex; diff --git a/sys/dev/irdma/fbsd_kcompat.h b/sys/dev/irdma/fbsd_kcompat.h index 630e49068a74..5e656cd9be9f 100644 --- a/sys/dev/irdma/fbsd_kcompat.h +++ b/sys/dev/irdma/fbsd_kcompat.h @@ -122,6 +122,7 @@ static inline int cq_validate_flags(u32 flags, u8 hw_rev) return flags & ~IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION ? -EOPNOTSUPP : 0; } + static inline u64 *irdma_next_pbl_addr(u64 *pbl, struct irdma_pble_info **pinfo, u32 *idx) { @@ -133,6 +134,20 @@ static inline u64 *irdma_next_pbl_addr(u64 *pbl, struct irdma_pble_info **pinfo, return (*pinfo)->addr; } + +static inline struct vnet * +irdma_cmid_to_vnet(struct iw_cm_id *cm_id) +{ + struct rdma_cm_id *rdma_id; + + if (!cm_id) + return &init_net; + + rdma_id = (struct rdma_cm_id *)cm_id->context; + + return rdma_id->route.addr.dev_addr.net; +} + struct ib_cq *irdma_create_cq(struct ib_device *ibdev, const struct ib_cq_init_attr *attr, struct ib_ucontext *context, diff --git a/sys/dev/irdma/irdma_cm.c b/sys/dev/irdma/irdma_cm.c index cb508bf52cb8..d34da57cc84d 100644 --- a/sys/dev/irdma/irdma_cm.c +++ b/sys/dev/irdma/irdma_cm.c @@ -1625,10 +1625,13 @@ static u8 irdma_iw_get_vlan_prio(u32 *loc_addr, u8 prio, bool ipv4) * vlan id and mac for that address. */ if_t -irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac) +irdma_netdev_vlan_ipv6(struct iw_cm_id *cm_id, u32 *addr, u16 *vlan_id, u8 *mac) { if_t ip_dev = NULL; struct in6_addr laddr6; +#ifdef VIMAGE + struct vnet *vnet = irdma_cmid_to_vnet(cm_id); +#endif struct ifaddr *ifa; u16 scope_id = 0; @@ -1642,7 +1645,11 @@ irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac) IN6_IS_ADDR_MC_INTFACELOCAL(&laddr6)) scope_id = ntohs(laddr6.__u6_addr.__u6_addr16[1]); +#ifdef VIMAGE + ip_dev = ip6_ifp_find(vnet, laddr6, scope_id); +#else ip_dev = ip6_ifp_find(&init_net, laddr6, scope_id); +#endif if (ip_dev) { if (vlan_id) *vlan_id = rdma_vlan_dev_vlan_id(ip_dev); @@ -1659,12 +1666,19 @@ irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac) * @addr: local IPv4 address */ u16 -irdma_get_vlan_ipv4(u32 *addr) +irdma_get_vlan_ipv4(struct iw_cm_id *cm_id, u32 *addr) { if_t netdev; +#ifdef VIMAGE + struct vnet *vnet = irdma_cmid_to_vnet(cm_id); +#endif u16 vlan_id = 0xFFFF; +#ifdef VIMAGE + netdev = ip_ifp_find(vnet, htonl(addr[0])); +#else netdev = ip_ifp_find(&init_net, htonl(addr[0])); +#endif if (netdev) { vlan_id = rdma_vlan_dev_vlan_id(netdev); dev_put(netdev); @@ -2060,8 +2074,7 @@ irdma_cm_create_ah(struct irdma_cm_node *cm_node, bool wait) struct irdma_ah_info ah_info = {0}; struct irdma_device *iwdev = cm_node->iwdev; #ifdef VIMAGE - struct rdma_cm_id *rdma_id = (struct rdma_cm_id *)cm_node->cm_id->context; - struct vnet *vnet = rdma_id->route.addr.dev_addr.net; + struct vnet *vnet = irdma_cmid_to_vnet(cm_node->cm_id); #endif ether_addr_copy(ah_info.mac_addr, if_getlladdr(iwdev->netdev)); @@ -3521,11 +3534,11 @@ irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) if (((struct sockaddr_in *)&cm_id->local_addr)->sin_family == AF_INET) { cm_node->ipv4 = true; - cm_node->vlan_id = irdma_get_vlan_ipv4(cm_node->loc_addr); + cm_node->vlan_id = irdma_get_vlan_ipv4(cm_id, cm_node->loc_addr); } else { cm_node->ipv4 = false; - irdma_netdev_vlan_ipv6(cm_node->loc_addr, &cm_node->vlan_id, - NULL); + irdma_netdev_vlan_ipv6(cm_id, cm_node->loc_addr, + &cm_node->vlan_id, NULL); } irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM, "Accept vlan_id=%d\n", cm_node->vlan_id); @@ -3720,7 +3733,7 @@ irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) cm_info.rem_addr[0] = ntohl(raddr->sin_addr.s_addr); cm_info.loc_port = ntohs(laddr->sin_port); cm_info.rem_port = ntohs(raddr->sin_port); - cm_info.vlan_id = irdma_get_vlan_ipv4(cm_info.loc_addr); + cm_info.vlan_id = irdma_get_vlan_ipv4(cm_id, cm_info.loc_addr); } else { if (iwdev->vsi.mtu < IRDMA_MIN_MTU_IPV6) return -EINVAL; @@ -3732,7 +3745,7 @@ irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) raddr6->sin6_addr.__u6_addr.__u6_addr32); cm_info.loc_port = ntohs(laddr6->sin6_port); cm_info.rem_port = ntohs(raddr6->sin6_port); - irdma_netdev_vlan_ipv6(cm_info.loc_addr, &cm_info.vlan_id, NULL); + irdma_netdev_vlan_ipv6(cm_id, cm_info.loc_addr, &cm_info.vlan_id, NULL); } cm_info.cm_id = cm_id; cm_info.qh_qpid = iwdev->vsi.ilq->qp_id; @@ -3847,7 +3860,7 @@ irdma_create_listen(struct iw_cm_id *cm_id, int backlog) cm_info.loc_port = ntohs(laddr->sin_port); if (laddr->sin_addr.s_addr != htonl(INADDR_ANY)) { - cm_info.vlan_id = irdma_get_vlan_ipv4(cm_info.loc_addr); + cm_info.vlan_id = irdma_get_vlan_ipv4(cm_id, cm_info.loc_addr); } else { cm_info.vlan_id = 0xFFFF; wildcard = true; @@ -3861,7 +3874,7 @@ irdma_create_listen(struct iw_cm_id *cm_id, int backlog) laddr6->sin6_addr.__u6_addr.__u6_addr32); cm_info.loc_port = ntohs(laddr6->sin6_port); if (!IN6_IS_ADDR_UNSPECIFIED(&laddr6->sin6_addr)) { - irdma_netdev_vlan_ipv6(cm_info.loc_addr, + irdma_netdev_vlan_ipv6(cm_id, cm_info.loc_addr, &cm_info.vlan_id, NULL); } else { cm_info.vlan_id = 0xFFFF; diff --git a/sys/dev/irdma/irdma_main.h b/sys/dev/irdma/irdma_main.h index 8e304cae551f..3d6dd4e3f9db 100644 --- a/sys/dev/irdma/irdma_main.h +++ b/sys/dev/irdma/irdma_main.h @@ -572,8 +572,9 @@ void irdma_gen_ae(struct irdma_pci_f *rf, struct irdma_sc_qp *qp, struct irdma_gen_ae_info *info, bool wait); void irdma_copy_ip_ntohl(u32 *dst, __be32 *src); void irdma_copy_ip_htonl(__be32 *dst, u32 *src); -u16 irdma_get_vlan_ipv4(u32 *addr); -if_t irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac); +u16 irdma_get_vlan_ipv4(struct iw_cm_id *cm_id, u32 *addr); +if_t irdma_netdev_vlan_ipv6(struct iw_cm_id *cm_id, u32 *addr, u16 *vlan_id, + u8 *mac); struct ib_mr *irdma_reg_phys_mr(struct ib_pd *ib_pd, u64 addr, u64 size, int acc, u64 *iova_start); int irdma_upload_qp_context(struct irdma_qp *iwqp, bool freeze, bool raw); diff --git a/sys/dev/irdma/irdma_verbs.c b/sys/dev/irdma/irdma_verbs.c index 288b075ab79f..c0726d25b8ec 100644 --- a/sys/dev/irdma/irdma_verbs.c +++ b/sys/dev/irdma/irdma_verbs.c @@ -3217,7 +3217,7 @@ irdma_attach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid) if (!ipv6_addr_v4mapped((struct in6_addr *)ibgid)) { irdma_copy_ip_ntohl(ip_addr, sgid_addr.saddr_in6.sin6_addr.__u6_addr.__u6_addr32); - irdma_netdev_vlan_ipv6(ip_addr, &vlan_id, NULL); + irdma_netdev_vlan_ipv6(iwqp->cm_id, ip_addr, &vlan_id, NULL); ipv4 = false; irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_VERBS, "qp_id=%d, IP6address=%x:%x:%x:%x\n", ibqp->qp_num, @@ -3226,7 +3226,7 @@ irdma_attach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid) } else { ip_addr[0] = ntohl(sgid_addr.saddr_in.sin_addr.s_addr); ipv4 = true; - vlan_id = irdma_get_vlan_ipv4(ip_addr); + vlan_id = irdma_get_vlan_ipv4(iwqp->cm_id, ip_addr); irdma_mcast_mac_v4(ip_addr, dmac); irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_VERBS, "qp_id=%d, IP4address=%x, MAC=%x:%x:%x:%x:%x:%x\n",