From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
linux-rdma@vger.kernel.org, Yishai Hadas <yishaih@mellanox.com>
Subject: [PATCH rdma-next v1 02/11] RDMA/mlx4: Delete duplicated offsetofend implementation
Date: Tue, 10 Mar 2020 11:14:29 +0200 [thread overview]
Message-ID: <20200310091438.248429-3-leon@kernel.org> (raw)
In-Reply-To: <20200310091438.248429-1-leon@kernel.org>
From: Leon Romanovsky <leonro@mellanox.com>
Convert mlx4 to use in-kernel offsetofend() instead
of its duplicated implementation.
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx4/main.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 2f5d9b181848..a66518a5c938 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -434,9 +434,6 @@ int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
return real_index;
}
-#define field_avail(type, fld, sz) (offsetof(type, fld) + \
- sizeof(((type *)0)->fld) <= (sz))
-
static int mlx4_ib_query_device(struct ib_device *ibdev,
struct ib_device_attr *props,
struct ib_udata *uhw)
@@ -447,7 +444,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
int err;
int have_ib_ports;
struct mlx4_uverbs_ex_query_device cmd;
- struct mlx4_uverbs_ex_query_device_resp resp = {.comp_mask = 0};
+ struct mlx4_uverbs_ex_query_device_resp resp = {};
struct mlx4_clock_params clock_params;
if (uhw->inlen) {
@@ -602,7 +599,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
sizeof(struct mlx4_wqe_data_seg);
}
- if (field_avail(typeof(resp), rss_caps, uhw->outlen)) {
+ if (offsetofend(typeof(resp), rss_caps) <= uhw->outlen) {
if (props->rss_caps.supported_qpts) {
resp.rss_caps.rx_hash_function =
MLX4_IB_RX_HASH_FUNC_TOEPLITZ;
@@ -626,7 +623,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
sizeof(resp.rss_caps);
}
- if (field_avail(typeof(resp), tso_caps, uhw->outlen)) {
+ if (offsetofend(typeof(resp), tso_caps) <= uhw->outlen) {
if (dev->dev->caps.max_gso_sz &&
((mlx4_ib_port_link_layer(ibdev, 1) ==
IB_LINK_LAYER_ETHERNET) ||
--
2.24.1
next prev parent reply other threads:[~2020-03-10 9:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 9:14 [PATCH rdma-next v1 00/11] Add Enhanced Connection Established (ECE) Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 01/11] RDMA/cm: Add Enhanced Connection Establishment (ECE) bits Leon Romanovsky
2020-03-10 9:14 ` Leon Romanovsky [this message]
2020-03-10 9:14 ` [PATCH rdma-next v1 03/11] RDMA/efa: Use in-kernel offsetofend() to check field availability Leon Romanovsky
2020-03-13 13:44 ` Jason Gunthorpe
2020-03-13 13:57 ` Leon Romanovsky
2020-03-13 14:26 ` Jason Gunthorpe
2020-03-13 14:38 ` Leon Romanovsky
2020-03-15 7:44 ` Gal Pressman
2020-03-18 9:13 ` Leon Romanovsky
2020-03-19 0:08 ` Jason Gunthorpe
2020-03-10 9:14 ` [PATCH rdma-next v1 04/11] RDMA/mlx5: Use offsetofend() instead of duplicated variant Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 05/11] RDMA/cm: Delete not implemented CM peer to peer communication Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 06/11] RDMA/uapi: Add ECE definitions to UCMA Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 07/11] RDMA/ucma: Extend ucma_connect to receive ECE parameters Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 08/11] RDMA/ucma: Deliver ECE parameters through UCMA events Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 09/11] RDMA/cm: Send and receive ECE parameter over the wire Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 10/11] RDMA/cma: Connect ECE to rdma_accept Leon Romanovsky
2020-03-10 9:14 ` [PATCH rdma-next v1 11/11] RDMA/cma: Provide ECE reject reason Leon Romanovsky
2020-03-13 13:54 ` Jason Gunthorpe
2020-03-13 13:59 ` Leon Romanovsky
2020-03-13 13:53 ` [PATCH rdma-next v1 00/11] Add Enhanced Connection Established (ECE) Jason Gunthorpe
2020-03-13 14:00 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200310091438.248429-3-leon@kernel.org \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=yishaih@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.