From nobody Wed Sep 13 22:17:15 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 4RmFDq3bG3z4t1d4; Wed, 13 Sep 2023 22:17:15 +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 4RmFDq383Nz4J1D; Wed, 13 Sep 2023 22:17:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694643435; 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=aDJ1FcnsQOUtDjcHwsCs9LvY3odyHvq5NzagWmVRyf8=; b=ZZpEhE/R7hBEbHyHFwQ9mu0P16MbM5RWFIFh7SGxwvwaT1fQbon5wW0PpN7J+OZ6h9AU9f 9hLIhRNdwDlWIvwDdLy3VIJtT916ruCwzA0nbCiENjyY86VW5QMyU9kfh0sSB3IJNKQmRp ZJTm3VKA/2iZARYFzFIZFjXzzfIdgYCHlt138FTuto81saSHBL4HUZHNfSy1SxRCekb9Nl 5khdiANxJbGvWjAHVo9/1ci/ysgFSHy8vJEZADTCJnagEDgX9Of9Qs1hl0zr2d3sZ4UOw2 4RJfIaidTf65PQOtvuCHDHC4G8Z+78VWXWS6yPtzdMZ1qVos/v5NX32ZNbh6og== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694643435; a=rsa-sha256; cv=none; b=g2Zgs1zqlR9xH/ECnmLSzv7W7yUocP/iDGjgt2On2mDuGURigxo+RyQ24Pl6ycGZSagGyv 28ns49wAHFPuPnDFWv+Q76ccRyGBJ227IfNysZYgcF98vwNlt9A3HWqGH8JSEIiBDvwT4M L0X0RjAD38KynVC5Uex+YGOlanBqn/LiF7z2sjxtNvisXGMntaAy+oEEWVU0UMPGe1XaY3 N7Hld+fDoOfz+8xF5IeNQ7khDyqjnJtDv65izI6WNa+OdsH1FYlJ58HR1yKrm4HAo5ayGM z6lNYB0KXrPnt6M6YzsIyPu7o1EOPUyUIq9kJlxMq1kRRHQNytW9qt1KLS59CA== 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=1694643435; 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=aDJ1FcnsQOUtDjcHwsCs9LvY3odyHvq5NzagWmVRyf8=; b=dOPMeajwHoqdNY/Dryaw/e+jrUUZTb9jZGKVtTzA/l8vzsK/LaRsUVfhwqyFH/gC4BaTzx 8IyhXcsKV9IBtyy3AWwSTjfhfYpndKEyIr9BZgkygmMyHkyog2qiBo9/98IvRLZO98SKgM nMFKjhRI9updwykddMAp7EN4vCqg2axHMwHeWMiSSt13VlME/TVlv/SqdPLB/pPjfmYkZw NB0bRMhq+l4WFtoSIB3F7HIzZUQ2h7YMJwomn1KXckpe6qjD3Rcw8UIJrvi19c/phu3+3d Mt4zSV19FNgsUFZwGo/rMGCiToCPmy6RA5YLeOhR3vcobP2rbiPNjoSelHE2Ug== 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 4RmFDq256WzXFH; Wed, 13 Sep 2023 22:17:15 +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 38DMHFg3012452; Wed, 13 Sep 2023 22:17:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38DMHFvJ012449; Wed, 13 Sep 2023 22:17:15 GMT (envelope-from git) Date: Wed, 13 Sep 2023 22:17:15 GMT Message-Id: <202309132217.38DMHFvJ012449@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric Joyner Subject: git: bc3a013ccd23 - main - 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/main X-Git-Reftype: branch X-Git-Commit: bc3a013ccd23c50bb48f17211ffc36fe85d11e18 Auto-Submitted: auto-generated The branch main has been updated by erj: URL: https://cgit.FreeBSD.org/src/commit/?id=bc3a013ccd23c50bb48f17211ffc36fe85d11e18 commit bc3a013ccd23c50bb48f17211ffc36fe85d11e18 Author: Bartosz Sobczak AuthorDate: 2023-09-12 21:31:39 +0000 Commit: Eric Joyner CommitDate: 2023-09-13 22:16:15 +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@ MFC after: 1 day Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D41592 --- sys/dev/irdma/fbsd_kcompat.c | 6 ++---- sys/dev/irdma/fbsd_kcompat.h | 14 ++++++++++++++ sys/dev/irdma/irdma_cm.c | 35 ++++++++++++++++++++++++----------- sys/dev/irdma/irdma_main.h | 5 +++-- sys/dev/irdma/irdma_verbs.c | 4 ++-- 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/sys/dev/irdma/fbsd_kcompat.c b/sys/dev/irdma/fbsd_kcompat.c index 013f9279952e..fbfa5c9e5fc4 100644 --- a/sys/dev/irdma/fbsd_kcompat.c +++ b/sys/dev/irdma/fbsd_kcompat.c @@ -393,8 +393,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; @@ -492,8 +491,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 eb1e615fc048..f465f97167cc 100644 --- a/sys/dev/irdma/fbsd_kcompat.h +++ b/sys/dev/irdma/fbsd_kcompat.h @@ -121,6 +121,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; +} + #if __FreeBSD_version < 1400026 struct ib_cq *irdma_create_cq(struct ib_device *ibdev, const struct ib_cq_init_attr *attr, diff --git a/sys/dev/irdma/irdma_cm.c b/sys/dev/irdma/irdma_cm.c index 48aefda681cb..c1d5875961f0 100644 --- a/sys/dev/irdma/irdma_cm.c +++ b/sys/dev/irdma/irdma_cm.c @@ -1624,10 +1624,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; @@ -1641,7 +1644,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); @@ -1658,12 +1665,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)); @@ -3520,11 +3533,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); @@ -3719,7 +3732,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; @@ -3731,7 +3744,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; @@ -3846,7 +3859,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; @@ -3860,7 +3873,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 25c3fcfc939e..aa5bbee2fb77 100644 --- a/sys/dev/irdma/irdma_main.h +++ b/sys/dev/irdma/irdma_main.h @@ -584,8 +584,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 8b7b34f7b2fb..cda8041ab397 100644 --- a/sys/dev/irdma/irdma_verbs.c +++ b/sys/dev/irdma/irdma_verbs.c @@ -3336,7 +3336,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, @@ -3345,7 +3345,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",