From nobody Thu Jul 30 23:22:52 2026 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 4hB4xY3NxCz6nGwt; Thu, 30 Jul 2026 23:22:57 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hB4xY2l0Hz3Zbt; Thu, 30 Jul 2026 23:22:57 +0000 (UTC) (envelope-from bz@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785453777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zMMu+isujsEs1EgRsSgU5SeSetO22sxNRPlm6Om/47A=; b=NNuwtAyjfMzF3fILanGVy6DBiI8Skm/danDl9PJ5X+4o46rk8oBJno2QwE+NuRkChs18Ik PdqPpBSn1LhVBCHKB6biEzMnCiDZqkXIv5IPRD15AMvaJPx0wE1zANTUWR9H0eAYWmuTqd 3Ker/JAv2WmBjQbO1QsgRK5Y72Vs0DrAo6rDAr9c/BcuO/qkokoYpZaGqeLKXamK/Srtd6 7pbgJgUhRZbGTgegayzocJZ+G8uv8MudeZ2imAxgkG2AhPmqBTbCE7VmOZTEMKuNxyJD7g C2otUj9pOQGC4Dk2qGBzYig2vSX6r6FQ0Io2Tw1U7ZSsCOlAs/IsAyN4N7GUqg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785453777; a=rsa-sha256; cv=none; b=DGx6IED2YzSrzLNboLwh07xHEWU7u8MthgAHM4BNQAk/QpsRs+bhun/0oLYtxC5GFw52Q2 1vdkd/B3X7m9GIIq/JXBpHOkysdB50HzukudnlsjVKYm0zMjeUKQy9qKhWs7U+W7qG/23M ijK287N/PCuiamgxX2ARgUcUFQAYoAtb3EB7Mzoyr7PISMa2LQCLgADQHrZBu3PHrr1Dua AuXXQRfy+8ryX/Kw1prnAHtqxKwkznnKzwvHko7+0FOn4TjJm0aQKB2A40iDty6G20/M+X W7SRGJxon8MyA8JY9rY5oHoALbbftz0osh4PajXju3ALhGAPcXfFjPuKqNcZsw== 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=1785453777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zMMu+isujsEs1EgRsSgU5SeSetO22sxNRPlm6Om/47A=; b=kGHDTmdhJSdjvsIo6myaco2r6beri+Qiw5lBZBtrho1K4srJZceU9/SjktyO/tJzzIQs0d 2b4+ulLCn6S0qo9YYWus0biEwY9+SOCUphhtjm1i9vON/VMY3M76Fv/ZOcH5/fHEK6S+sI HnJroYBvqZ/igrvUYUbsCzcbVwvfqeZKign0QxBXbP+wwnvqcEkyMaVuEFJLrr4oPntVt7 sS295TFB9MH1l4dL0Z4AERAlmzrjAP6cgMbLDMsWzLVq/E5LFft6X9+TXkohCYrRQHTQDs BrIdaShw3tLBBxT04KEwbRORra9Bf/ae0IZrCuD9+gBs9Z1xnnvr16L3+yFNhg== Received: from mx-01.divo.sbone.de (mx-01.divo.sbone.de [IPv6:2003:a:140a:2200:6:594:fffe:19]) (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 ECDSA (prime256v1) client-digest SHA256) (Client CN "mx-01.divo.sbone.de", Issuer "YE2" (not verified)) (Authenticated sender: bz/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4hB4xX6sRwzBVd; Thu, 30 Jul 2026 23:22:56 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:1025]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by mx-01.divo.sbone.de (Postfix) with ESMTPS id 5FE82A64805; Thu, 30 Jul 2026 23:22:24 +0000 (UTC) Received: from content-filter.t4-02.sbone.de (content-filter.t4-02.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:2742]) (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) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id BF9EA2D029E9; Thu, 30 Jul 2026 23:22:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:4902:0:7404:2:1025]) by content-filter.t4-02.sbone.de (content-filter.t4-02.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:2742]) (amavisd-new, port 10024) with ESMTP id vdyAibWl4jp8; Thu, 30 Jul 2026 23:22:53 +0000 (UTC) Received: from nv.t4-02.sbone.de (nv.t4-02.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:22]) (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) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id D86E22D029D8; Thu, 30 Jul 2026 23:22:52 +0000 (UTC) Date: Thu, 30 Jul 2026 23:22:52 +0000 (UTC) From: "Bjoern A. Zeeb" To: John Baldwin cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: ea44c37d0bd1 - main - OFED: Add generic function to extract IB speed from netdev In-Reply-To: <6a6a4a27.40471.422e3907@gitrepo.freebsd.org> Message-ID: References: <6a6a4a27.40471.422e3907@gitrepo.freebsd.org> X-OpenPGP-Key-Id: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed On Wed, 29 Jul 2026, John Baldwin wrote: > The branch main has been updated by jhb: > > URL: https://cgit.FreeBSD.org/src/commit/?id=ea44c37d0bd15e796c85f84b57c211ac220c550c > > commit ea44c37d0bd15e796c85f84b57c211ac220c550c > Author: John Baldwin > AuthorDate: 2026-07-29 18:42:19 +0000 > Commit: John Baldwin > CommitDate: 2026-07-29 18:42:19 +0000 > > OFED: Add generic function to extract IB speed from netdev This is really confusing to me and I point this out given one of the many "this is not wireles" LinuxKPI parts I had to do in the past was to "divorce" netdev being an ifnet as one was aliased to the other in the past not allowing us to have the Linux native fields we nowhere used and had edited away (all before my time). And I was like "we have no support for any of this in LinuxKPI -- how can this work" until I saw the if_t. We should really start calling ifnet ifnet and no longer netdev unless we make netdev work on top of ifnet and it is a net_device again. /bz > Reviewed by: kib > Obtained from: Linux commit d41861942fc55c14b6280d9568a0d0112037f065 > Sponsored by: Chelsio Communications > Differential Revision: https://reviews.freebsd.org/D57952 > --- > sys/dev/irdma/fbsd_kcompat.h | 1 - > sys/dev/irdma/irdma_kcompat.c | 102 ---------------------------- > sys/ofed/drivers/infiniband/core/ib_verbs.c | 48 +++++++++++++ > sys/ofed/include/rdma/ib_verbs.h | 2 + > 4 files changed, 50 insertions(+), 103 deletions(-) > > diff --git a/sys/dev/irdma/fbsd_kcompat.h b/sys/dev/irdma/fbsd_kcompat.h > index 8050d528a9c0..c5ca18204d49 100644 > --- a/sys/dev/irdma/fbsd_kcompat.h > +++ b/sys/dev/irdma/fbsd_kcompat.h > @@ -147,7 +147,6 @@ void irdma_destroy_ah(struct ib_ah *ibah, u32 flags); > void irdma_destroy_ah_stub(struct ib_ah *ibah, u32 flags); > int irdma_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata); > int irdma_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata); > -int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width); > enum rdma_link_layer irdma_get_link_layer(struct ib_device *ibdev, > u8 port_num); > int irdma_roce_port_immutable(struct ib_device *ibdev, u8 port_num, > diff --git a/sys/dev/irdma/irdma_kcompat.c b/sys/dev/irdma/irdma_kcompat.c > index 03ddae317d58..7ee81ab5add6 100644 > --- a/sys/dev/irdma/irdma_kcompat.c > +++ b/sys/dev/irdma/irdma_kcompat.c > @@ -1768,108 +1768,6 @@ kc_set_rdma_uverbs_cmd_mask(struct irdma_device *iwdev) > iwdev->ibdev.uverbs_ex_cmd_mask |= BIT_ULL(IB_USER_VERBS_EX_CMD_CREATE_CQ); > } > > -static void > -ib_get_width_and_speed(u32 netdev_speed, u32 lanes, > - u16 *speed, u8 *width) > -{ > - if (!lanes) { > - if (netdev_speed <= SPEED_1000) { > - *width = IB_WIDTH_1X; > - *speed = IB_SPEED_SDR; > - } else if (netdev_speed <= SPEED_10000) { > - *width = IB_WIDTH_1X; > - *speed = IB_SPEED_FDR10; > - } else if (netdev_speed <= SPEED_20000) { > - *width = IB_WIDTH_4X; > - *speed = IB_SPEED_DDR; > - } else if (netdev_speed <= SPEED_25000) { > - *width = IB_WIDTH_1X; > - *speed = IB_SPEED_EDR; > - } else if (netdev_speed <= SPEED_40000) { > - *width = IB_WIDTH_4X; > - *speed = IB_SPEED_FDR10; > - } else if (netdev_speed <= SPEED_50000) { > - *width = IB_WIDTH_2X; > - *speed = IB_SPEED_EDR; > - } else if (netdev_speed <= SPEED_100000) { > - *width = IB_WIDTH_4X; > - *speed = IB_SPEED_EDR; > - } else if (netdev_speed <= SPEED_200000) { > - *width = IB_WIDTH_4X; > - *speed = IB_SPEED_HDR; > - } else { > - *width = IB_WIDTH_4X; > - *speed = IB_SPEED_NDR; > - } > - > - return; > - } > - > - switch (lanes) { > - case 1: > - *width = IB_WIDTH_1X; > - break; > - case 2: > - *width = IB_WIDTH_2X; > - break; > - case 4: > - *width = IB_WIDTH_4X; > - break; > - case 8: > - *width = IB_WIDTH_8X; > - break; > - case 12: > - *width = IB_WIDTH_12X; > - break; > - default: > - *width = IB_WIDTH_1X; > - } > - > - switch (netdev_speed / lanes) { > - case SPEED_2500: > - *speed = IB_SPEED_SDR; > - break; > - case SPEED_5000: > - *speed = IB_SPEED_DDR; > - break; > - case SPEED_10000: > - *speed = IB_SPEED_FDR10; > - break; > - case SPEED_14000: > - *speed = IB_SPEED_FDR; > - break; > - case SPEED_25000: > - *speed = IB_SPEED_EDR; > - break; > - case SPEED_50000: > - *speed = IB_SPEED_HDR; > - break; > - case SPEED_100000: > - *speed = IB_SPEED_NDR; > - break; > - default: > - *speed = IB_SPEED_SDR; > - } > -} > - > -int > -ib_get_eth_speed(struct ib_device *ibdev, u32 port_num, u16 *speed, u8 *width) > -{ > - if_t netdev = ibdev->get_netdev(ibdev, port_num); > - u32 netdev_speed, lanes; > - > - if (!netdev) > - return -ENODEV; > - > - netdev_speed = (u32)if_getbaudrate(netdev); > - dev_put(netdev); > - lanes = 0; > - > - ib_get_width_and_speed(netdev_speed, lanes, speed, width); > - > - return 0; > -} > - > u64 > irdma_mac_to_u64(const u8 *eth_add) > { > diff --git a/sys/ofed/drivers/infiniband/core/ib_verbs.c b/sys/ofed/drivers/infiniband/core/ib_verbs.c > index 532bba6325de..35e6ace39a01 100644 > --- a/sys/ofed/drivers/infiniband/core/ib_verbs.c > +++ b/sys/ofed/drivers/infiniband/core/ib_verbs.c > @@ -1698,6 +1698,54 @@ int ib_modify_qp_with_udata(struct ib_qp *ib_qp, struct ib_qp_attr *attr, > } > EXPORT_SYMBOL(ib_modify_qp_with_udata); > > +int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u16 *speed, u8 *width) > +{ > + uint64_t netdev_speed; > + if_t netdev; > + > + if (rdma_port_get_link_layer(dev, port_num) != IB_LINK_LAYER_ETHERNET) > + return -EINVAL; > + > + if (!dev->get_netdev) > + return -EOPNOTSUPP; > + > + netdev = dev->get_netdev(dev, port_num); > + if (!netdev) > + return -ENODEV; > + > + netdev_speed = if_getbaudrate(netdev); > + > + dev_put(netdev); > + > + if (netdev_speed == 0) { > + netdev_speed = IF_Mbps(1000); > + if_printf(netdev, "speed is unknown, defaulting to 1Gbps\n"); > + } > + > + if (netdev_speed <= IF_Mbps(1000)) { > + *width = IB_WIDTH_1X; > + *speed = IB_SPEED_SDR; > + } else if (netdev_speed <= IF_Mbps(10000)) { > + *width = IB_WIDTH_1X; > + *speed = IB_SPEED_FDR10; > + } else if (netdev_speed <= IF_Mbps(20000)) { > + *width = IB_WIDTH_4X; > + *speed = IB_SPEED_DDR; > + } else if (netdev_speed <= IF_Mbps(25000)) { > + *width = IB_WIDTH_1X; > + *speed = IB_SPEED_EDR; > + } else if (netdev_speed <= IF_Mbps(40000)) { > + *width = IB_WIDTH_4X; > + *speed = IB_SPEED_FDR10; > + } else { > + *width = IB_WIDTH_4X; > + *speed = IB_SPEED_EDR; > + } > + > + return 0; > +} > +EXPORT_SYMBOL(ib_get_eth_speed); > + > int ib_modify_qp(struct ib_qp *qp, > struct ib_qp_attr *qp_attr, > int qp_attr_mask) > diff --git a/sys/ofed/include/rdma/ib_verbs.h b/sys/ofed/include/rdma/ib_verbs.h > index 8ac13023020b..3c81440e782f 100644 > --- a/sys/ofed/include/rdma/ib_verbs.h > +++ b/sys/ofed/include/rdma/ib_verbs.h > @@ -3972,6 +3972,8 @@ struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile); > > int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs); > > +int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u16 *speed, u8 *width); > + > static inline u8 *rdma_ah_retrieve_dmac(struct rdma_ah_attr *attr) > { > if (attr->type == RDMA_AH_ATTR_TYPE_ROCE) > > -- Bjoern A. Zeeb r15:7