Date: Wed, 24 Jun 2026 19:51:08 +0000 From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 38d9ce1f58ea - main - OFED: Various changes from Linux 4.10 Message-ID: <6a3c352c.44b76.30ebdbee@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=38d9ce1f58ea6e2dc185fda0d9541a38d594ffc1 commit 38d9ce1f58ea6e2dc185fda0d9541a38d594ffc1 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2026-06-24 19:30:55 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2026-06-24 19:30:55 +0000 OFED: Various changes from Linux 4.10 This contains changes from the following Linux commits: 850d8fd76507 IB/mlx4: Handle IPv4 header when demultiplexing MAD a0b3455fcb2d IB/core: Remove debug prints after allocation failure 74226649f42d IB/ipoib: Remove and fix debug prints after allocation failure 870b28524552 IB/mthca: Remove debug prints after allocation failure aa6aae38f7fb IB/core: Release allocated memory in cache setup failure f73a1dbc45a5 infiniband: remove WARN that is not kernel bug 5f24410408fd rdma_cm: add rdma_consumer_reject_data helper function 5042a73d3e9d rdma_cm: add rdma_is_consumer_reject() helper function d3f4aadd614c RDMA/core: Add the function ib_mtu_int_to_enum Tested by: Wafa Hamzah <wafah@nvidia.com> (mlx5_ib) Tested by: John Baldwin <jhb@FreeBSD.org> (iw_cxgbe) Sponsored by: Chelsio Communications --- sys/dev/cxgbe/iw_cxgbe/provider.c | 11 +------- sys/dev/irdma/irdma_kcompat.c | 15 ---------- sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c | 22 ++++++++++++++- sys/dev/mthca/mthca_reset.c | 4 --- sys/ofed/drivers/infiniband/core/ib_agent.c | 1 - sys/ofed/drivers/infiniband/core/ib_cache.c | 16 +++++------ sys/ofed/drivers/infiniband/core/ib_cma.c | 29 ++++++++++++++++++++ sys/ofed/drivers/infiniband/core/ib_device.c | 5 +--- sys/ofed/drivers/infiniband/core/ib_fmr_pool.c | 1 - .../drivers/infiniband/core/ib_roce_gid_mgmt.c | 18 +++--------- sys/ofed/drivers/infiniband/core/ib_ucm.c | 5 +++- sys/ofed/drivers/infiniband/core/ib_ucma.c | 5 +++- sys/ofed/drivers/infiniband/core/ib_uverbs_main.c | 2 +- sys/ofed/drivers/infiniband/core/ib_verbs.c | 16 ++++++----- sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c | 8 +----- sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c | 5 +--- sys/ofed/include/rdma/ib_verbs.h | 32 ++++++++++++++++++++++ sys/ofed/include/rdma/rdma_cm.h | 17 ++++++++++++ 18 files changed, 132 insertions(+), 80 deletions(-) diff --git a/sys/dev/cxgbe/iw_cxgbe/provider.c b/sys/dev/cxgbe/iw_cxgbe/provider.c index 511caa436969..20803cb022d9 100644 --- a/sys/dev/cxgbe/iw_cxgbe/provider.c +++ b/sys/dev/cxgbe/iw_cxgbe/provider.c @@ -351,16 +351,7 @@ c4iw_query_port(struct ib_device *ibdev, u8 port, struct ib_port_attr *props) memset(props, 0, sizeof(struct ib_port_attr)); props->max_mtu = IB_MTU_4096; - if (if_getmtu(ifp) >= 4096) - props->active_mtu = IB_MTU_4096; - else if (if_getmtu(ifp) >= 2048) - props->active_mtu = IB_MTU_2048; - else if (if_getmtu(ifp) >= 1024) - props->active_mtu = IB_MTU_1024; - else if (if_getmtu(ifp) >= 512) - props->active_mtu = IB_MTU_512; - else - props->active_mtu = IB_MTU_256; + props->active_mtu = ib_mtu_int_to_enum(if_getmtu(ifp)); props->state = pi->link_cfg.link_ok ? IB_PORT_ACTIVE : IB_PORT_DOWN; props->port_cap_flags = IB_PORT_CM_SUP | diff --git a/sys/dev/irdma/irdma_kcompat.c b/sys/dev/irdma/irdma_kcompat.c index 4d02bd08ca65..0cf4b6b0c64e 100644 --- a/sys/dev/irdma/irdma_kcompat.c +++ b/sys/dev/irdma/irdma_kcompat.c @@ -1772,21 +1772,6 @@ irdma_get_link_layer(struct ib_device *ibdev, return IB_LINK_LAYER_ETHERNET; } -inline enum ib_mtu -ib_mtu_int_to_enum(int mtu) -{ - if (mtu >= 4096) - return IB_MTU_4096; - else if (mtu >= 2048) - return IB_MTU_2048; - else if (mtu >= 1024) - return IB_MTU_1024; - else if (mtu >= 512) - return IB_MTU_512; - else - return IB_MTU_256; -} - inline void kc_set_roce_uverbs_cmd_mask(struct irdma_device *iwdev) { diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c index f7c8aeb0b492..65d13d1947ea 100644 --- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c +++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c @@ -479,6 +479,23 @@ static int find_slave_port_pkey_ix(struct mlx4_ib_dev *dev, int slave, return -EINVAL; } +static int get_gids_from_l3_hdr(struct ib_grh *grh, union ib_gid *sgid, + union ib_gid *dgid) +{ + int version = ib_get_rdma_header_version((const union rdma_network_hdr *)grh); + enum rdma_network_type net_type; + + if (version == 4) + net_type = RDMA_NETWORK_IPV4; + else if (version == 6) + net_type = RDMA_NETWORK_IPV6; + else + return -EINVAL; + + return ib_get_gids_from_rdma_hdr((union rdma_network_hdr *)grh, net_type, + sgid, dgid); +} + int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port, enum ib_qp_type dest_qpt, struct ib_wc *wc, struct ib_grh *grh, struct ib_mad *mad) @@ -537,7 +554,10 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port, memset(&attr, 0, sizeof attr); attr.port_num = port; if (is_eth) { - memcpy(&attr.grh.dgid.raw[0], &grh->dgid.raw[0], 16); + union ib_gid sgid; + + if (get_gids_from_l3_hdr(grh, &sgid, &attr.grh.dgid)) + return -EINVAL; attr.ah_flags = IB_AH_GRH; } ah = ib_create_ah(tun_ctx->pd, &attr, 0); diff --git a/sys/dev/mthca/mthca_reset.c b/sys/dev/mthca/mthca_reset.c index f571bd6d1ca2..ec66138aa913 100644 --- a/sys/dev/mthca/mthca_reset.c +++ b/sys/dev/mthca/mthca_reset.c @@ -105,8 +105,6 @@ int mthca_reset(struct mthca_dev *mdev) hca_header = kmalloc(256, GFP_KERNEL); if (!hca_header) { err = -ENOMEM; - mthca_err(mdev, "Couldn't allocate memory to save HCA " - "PCI header, aborting.\n"); goto out; } @@ -129,8 +127,6 @@ int mthca_reset(struct mthca_dev *mdev) bridge_header = kmalloc(256, GFP_KERNEL); if (!bridge_header) { err = -ENOMEM; - mthca_err(mdev, "Couldn't allocate memory to save HCA " - "bridge PCI header, aborting.\n"); goto out; } diff --git a/sys/ofed/drivers/infiniband/core/ib_agent.c b/sys/ofed/drivers/infiniband/core/ib_agent.c index 4e175036117e..ad2a85d29f96 100644 --- a/sys/ofed/drivers/infiniband/core/ib_agent.c +++ b/sys/ofed/drivers/infiniband/core/ib_agent.c @@ -158,7 +158,6 @@ int ib_agent_port_open(struct ib_device *device, int port_num) /* Create new device info */ port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL); if (!port_priv) { - dev_err(&device->dev, "No memory for ib_agent_port_private\n"); ret = -ENOMEM; goto error1; } diff --git a/sys/ofed/drivers/infiniband/core/ib_cache.c b/sys/ofed/drivers/infiniband/core/ib_cache.c index d2cc680796ef..1f5ef4c5517e 100644 --- a/sys/ofed/drivers/infiniband/core/ib_cache.c +++ b/sys/ofed/drivers/infiniband/core/ib_cache.c @@ -786,12 +786,8 @@ static int _gid_table_setup_one(struct ib_device *ib_dev) int err = 0; table = kcalloc(ib_dev->phys_port_cnt, sizeof(*table), GFP_KERNEL); - - if (!table) { - pr_warn("failed to allocate ib gid cache for %s\n", - ib_dev->name); + if (!table) return -ENOMEM; - } for (port = 0; port < ib_dev->phys_port_cnt; port++) { u8 rdma_port = port + rdma_start_port(ib_dev); @@ -1186,14 +1182,13 @@ int ib_cache_setup_one(struct ib_device *device) GFP_KERNEL); if (!device->cache.pkey_cache || !device->cache.lmc_cache) { - pr_warn("Couldn't allocate cache for %s\n", device->name); - return -ENOMEM; + err = -ENOMEM; + goto free; } err = gid_table_setup_one(device); if (err) - /* Allocated memory will be cleaned in the release function */ - return err; + goto free; for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) ib_cache_update(device, p + rdma_start_port(device)); @@ -1208,6 +1203,9 @@ int ib_cache_setup_one(struct ib_device *device) err: gid_table_cleanup_one(device); +free: + kfree(device->cache.pkey_cache); + kfree(device->cache.lmc_cache); return err; } diff --git a/sys/ofed/drivers/infiniband/core/ib_cma.c b/sys/ofed/drivers/infiniband/core/ib_cma.c index 43f0e4c7bb32..07d598af3471 100644 --- a/sys/ofed/drivers/infiniband/core/ib_cma.c +++ b/sys/ofed/drivers/infiniband/core/ib_cma.c @@ -127,6 +127,35 @@ const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id, } EXPORT_SYMBOL(rdma_reject_msg); +bool rdma_is_consumer_reject(struct rdma_cm_id *id, int reason) +{ + if (rdma_ib_or_roce(id->device, id->port_num)) + return reason == IB_CM_REJ_CONSUMER_DEFINED; + + if (rdma_protocol_iwarp(id->device, id->port_num)) + return reason == -ECONNREFUSED; + + WARN_ON_ONCE(1); + return false; +} +EXPORT_SYMBOL(rdma_is_consumer_reject); + +const void *rdma_consumer_reject_data(struct rdma_cm_id *id, + struct rdma_cm_event *ev, u8 *data_len) +{ + const void *p; + + if (rdma_is_consumer_reject(id, ev->status)) { + *data_len = ev->param.conn.private_data_len; + p = ev->param.conn.private_data; + } else { + *data_len = 0; + p = NULL; + } + return p; +} +EXPORT_SYMBOL(rdma_consumer_reject_data); + static int cma_check_linklocal(struct rdma_dev_addr *, struct sockaddr *); static void cma_add_one(struct ib_device *device); static void cma_remove_one(struct ib_device *device, void *client_data); diff --git a/sys/ofed/drivers/infiniband/core/ib_device.c b/sys/ofed/drivers/infiniband/core/ib_device.c index 4b7ab9bf9659..51e3908c3c9f 100644 --- a/sys/ofed/drivers/infiniband/core/ib_device.c +++ b/sys/ofed/drivers/infiniband/core/ib_device.c @@ -248,11 +248,8 @@ static int add_client_context(struct ib_device *device, struct ib_client *client unsigned long flags; context = kmalloc(sizeof *context, GFP_KERNEL); - if (!context) { - pr_warn("Couldn't allocate client context for %s/%s\n", - device->name, client->name); + if (!context) return -ENOMEM; - } context->client = client; context->data = NULL; diff --git a/sys/ofed/drivers/infiniband/core/ib_fmr_pool.c b/sys/ofed/drivers/infiniband/core/ib_fmr_pool.c index b7587b7420ee..59a077d5caf6 100644 --- a/sys/ofed/drivers/infiniband/core/ib_fmr_pool.c +++ b/sys/ofed/drivers/infiniband/core/ib_fmr_pool.c @@ -250,7 +250,6 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket, GFP_KERNEL); if (!pool->cache_bucket) { - pr_warn(PFX "Failed to allocate cache in pool\n"); ret = -ENOMEM; goto out_free_pool; } diff --git a/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c b/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c index 3b6413d47e23..50932d6ec675 100644 --- a/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c +++ b/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c @@ -168,11 +168,8 @@ roce_gid_update_addr_ifa4_cb(void *arg, struct ifaddr *ifa, u_int count) struct ipx_entry *entry; entry = kzalloc(sizeof(*entry), GFP_ATOMIC); - if (entry == NULL) { - pr_warn("roce_gid_update_addr_callback: " - "couldn't allocate entry for IPv4 update\n"); + if (entry == NULL) return (0); - } entry->ipx_addr.v4 = *((struct sockaddr_in *)ifa->ifa_addr); entry->ndev = ifa->ifa_ifp; STAILQ_INSERT_TAIL(ipx_head, entry, entry); @@ -189,11 +186,8 @@ roce_gid_update_addr_ifa6_cb(void *arg, struct ifaddr *ifa, u_int count) struct ipx_entry *entry; entry = kzalloc(sizeof(*entry), GFP_ATOMIC); - if (entry == NULL) { - pr_warn("roce_gid_update_addr_callback: " - "couldn't allocate entry for IPv6 update\n"); + if (entry == NULL) return (0); - } entry->ipx_addr.v6 = *((struct sockaddr_in6 *)ifa->ifa_addr); entry->ndev = ifa->ifa_ifp; @@ -345,10 +339,8 @@ retry: } work = kmalloc(sizeof(*work), GFP_ATOMIC); - if (!work) { - pr_warn("roce_gid_mgmt: Couldn't allocate work for addr_event\n"); + if (!work) return; - } INIT_WORK(&work->work, roce_gid_queue_scan_event_handler); dev_hold(ndev); @@ -375,10 +367,8 @@ roce_gid_delete_all_event(if_t ndev) struct roce_netdev_event_work *work; work = kmalloc(sizeof(*work), GFP_ATOMIC); - if (!work) { - pr_warn("roce_gid_mgmt: Couldn't allocate work for addr_event\n"); + if (!work) return; - } INIT_WORK(&work->work, roce_gid_delete_all_event_handler); dev_hold(ndev); diff --git a/sys/ofed/drivers/infiniband/core/ib_ucm.c b/sys/ofed/drivers/infiniband/core/ib_ucm.c index 9666051d1c4f..f0ca162dadf0 100644 --- a/sys/ofed/drivers/infiniband/core/ib_ucm.c +++ b/sys/ofed/drivers/infiniband/core/ib_ucm.c @@ -1105,8 +1105,11 @@ static ssize_t ib_ucm_write(struct file *filp, const char __user *buf, struct ib_ucm_cmd_hdr hdr; ssize_t result; - if (WARN_ON_ONCE(!ib_safe_file_access(filp))) + if (!ib_safe_file_access(filp)) { + pr_err_once("ucm_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n", + current->pid, current->comm); return -EACCES; + } if (len < sizeof(hdr)) return -EINVAL; diff --git a/sys/ofed/drivers/infiniband/core/ib_ucma.c b/sys/ofed/drivers/infiniband/core/ib_ucma.c index 6d024a74a23a..b7b45f6ae0a9 100644 --- a/sys/ofed/drivers/infiniband/core/ib_ucma.c +++ b/sys/ofed/drivers/infiniband/core/ib_ucma.c @@ -1612,8 +1612,11 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf, struct rdma_ucm_cmd_hdr hdr; ssize_t ret; - if (WARN_ON_ONCE(!ib_safe_file_access(filp))) + if (!ib_safe_file_access(filp)) { + pr_err_once("ucma_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n", + current->pid, current->comm); return -EACCES; + } if (len < sizeof(hdr)) return -EINVAL; diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c b/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c index c01ee4a954ed..1586c23d28d4 100644 --- a/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c +++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c @@ -566,7 +566,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, ssize_t ret; if (!ib_safe_file_access(filp)) { - pr_warn_once("uverbs_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n", + pr_err_once("uverbs_write: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n", current->pid, current->comm); return -EACCES; } diff --git a/sys/ofed/drivers/infiniband/core/ib_verbs.c b/sys/ofed/drivers/infiniband/core/ib_verbs.c index 9ae6854bab92..4a8a64fabcb4 100644 --- a/sys/ofed/drivers/infiniband/core/ib_verbs.c +++ b/sys/ofed/drivers/infiniband/core/ib_verbs.c @@ -437,7 +437,7 @@ struct ib_ah *ib_create_user_ah(struct ib_pd *pd, } EXPORT_SYMBOL(ib_create_user_ah); -static int ib_get_header_version(const union rdma_network_hdr *hdr) +int ib_get_rdma_header_version(const union rdma_network_hdr *hdr) { const struct ip *ip4h = (const struct ip *)&hdr->roce4grh; struct ip ip4h_checked; @@ -470,6 +470,7 @@ static int ib_get_header_version(const union rdma_network_hdr *hdr) return 4; return 6; } +EXPORT_SYMBOL(ib_get_rdma_header_version); static enum rdma_network_type ib_get_net_type_by_grh(struct ib_device *device, u8 port_num, @@ -480,7 +481,7 @@ static enum rdma_network_type ib_get_net_type_by_grh(struct ib_device *device, if (rdma_protocol_ib(device, port_num)) return RDMA_NETWORK_IB; - grh_version = ib_get_header_version((const union rdma_network_hdr *)grh); + grh_version = ib_get_rdma_header_version((const union rdma_network_hdr *)grh); if (grh_version == 4) return RDMA_NETWORK_IPV4; @@ -536,9 +537,9 @@ static int get_sgid_index_from_eth(struct ib_device *device, u8 port_num, &context, gid_index); } -static int get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr, - enum rdma_network_type net_type, - union ib_gid *sgid, union ib_gid *dgid) +int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr, + enum rdma_network_type net_type, + union ib_gid *sgid, union ib_gid *dgid) { struct sockaddr_in src_in; struct sockaddr_in dst_in; @@ -568,6 +569,7 @@ static int get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr, return -EINVAL; } } +EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr); int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, const struct ib_wc *wc, const struct ib_grh *grh, @@ -590,8 +592,8 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, net_type = ib_get_net_type_by_grh(device, port_num, grh); gid_type = ib_network_to_gid_type(net_type); } - ret = get_gids_from_rdma_hdr((const union rdma_network_hdr *)grh, net_type, - &sgid, &dgid); + ret = ib_get_gids_from_rdma_hdr((const union rdma_network_hdr *)grh, net_type, + &sgid, &dgid); if (ret) return ret; diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 61db58d2b6c7..69bb059aac3b 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c @@ -309,11 +309,8 @@ static int ipoib_cm_nonsrq_init_rx(struct ipoib_dev_priv *priv, int i; rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring); - if (!rx->rx_ring) { - printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n", - priv->ca->name, ipoib_recvq_size); + if (!rx->rx_ring) return -ENOMEM; - } t = kmalloc(sizeof *t, GFP_KERNEL); if (!t) { @@ -1008,7 +1005,6 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, p->tx_ring = vzalloc(ipoib_sendq_size * sizeof *p->tx_ring); if (!p->tx_ring) { - ipoib_warn(priv, "failed to allocate tx ring\n"); ret = -ENOMEM; goto err_tx; } @@ -1367,8 +1363,6 @@ static void ipoib_cm_create_srq(struct ipoib_dev_priv *priv, int max_sge) priv->cm.srq_ring = vzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring); if (!priv->cm.srq_ring) { - printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n", - priv->ca->name, ipoib_recvq_size); ib_destroy_srq(priv->cm.srq); priv->cm.srq = NULL; return; diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c index d37021a54eb8..7bc01d4ce2c5 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -793,11 +793,8 @@ ipoib_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca, int port) /* Allocate RX/TX "rings" to hold queued mbs */ priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring, GFP_KERNEL); - if (!priv->rx_ring) { - printk(KERN_WARNING "%s: failed to allocate RX ring (%d entries)\n", - ca->name, ipoib_recvq_size); + if (!priv->rx_ring) goto out; - } priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring); if (!priv->tx_ring) { diff --git a/sys/ofed/include/rdma/ib_verbs.h b/sys/ofed/include/rdma/ib_verbs.h index b495c1da6c57..d88c9fb2b3c0 100644 --- a/sys/ofed/include/rdma/ib_verbs.h +++ b/sys/ofed/include/rdma/ib_verbs.h @@ -413,6 +413,20 @@ static inline int ib_mtu_enum_to_int(enum ib_mtu mtu) } } +static inline enum ib_mtu ib_mtu_int_to_enum(int mtu) +{ + if (mtu >= 4096) + return IB_MTU_4096; + else if (mtu >= 2048) + return IB_MTU_2048; + else if (mtu >= 1024) + return IB_MTU_1024; + else if (mtu >= 512) + return IB_MTU_512; + else + return IB_MTU_256; +} + enum ib_port_state { IB_PORT_NOP = 0, IB_PORT_DOWN = 1, @@ -3021,6 +3035,24 @@ struct ib_ah *ib_create_user_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr, struct ib_udata *udata); +/** + * ib_get_gids_from_rdma_hdr - Get sgid and dgid from GRH or IPv4 header + * work completion. + * @hdr: the L3 header to parse + * @net_type: type of header to parse + * @sgid: place to store source gid + * @dgid: place to store destination gid + */ +int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr, + enum rdma_network_type net_type, + union ib_gid *sgid, union ib_gid *dgid); + +/** + * ib_get_rdma_header_version - Get the header version + * @hdr: the L3 header to parse + */ +int ib_get_rdma_header_version(const union rdma_network_hdr *hdr); + /** * ib_init_ah_from_wc - Initializes address handle attributes from a * work completion. diff --git a/sys/ofed/include/rdma/rdma_cm.h b/sys/ofed/include/rdma/rdma_cm.h index 1251aad58e85..df06e23c1db1 100644 --- a/sys/ofed/include/rdma/rdma_cm.h +++ b/sys/ofed/include/rdma/rdma_cm.h @@ -398,5 +398,22 @@ __be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr); */ const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id, int reason); +/** + * rdma_is_consumer_reject - return true if the consumer rejected the connect + * request. + * @id: Communication identifier that received the REJECT event. + * @reason: Value returned in the REJECT event status field. + */ +bool rdma_is_consumer_reject(struct rdma_cm_id *id, int reason); + +/** + * rdma_consumer_reject_data - return the consumer reject private data and + * length, if any. + * @id: Communication identifier that received the REJECT event. + * @ev: RDMA CM reject event. + * @data_len: Pointer to the resulting length of the consumer data. + */ +const void *rdma_consumer_reject_data(struct rdma_cm_id *id, + struct rdma_cm_event *ev, u8 *data_len); #endif /* RDMA_CM_H */home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a3c352c.44b76.30ebdbee>
