All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Huy Nguyen <huyn@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 03/12] net/mlx5: Add MLX5_SET16 and MLX5_GET16
Date: Sat,  4 Nov 2017 01:50:21 -0700	[thread overview]
Message-ID: <20171104085030.25430-4-saeedm@mellanox.com> (raw)
In-Reply-To: <20171104085030.25430-1-saeedm@mellanox.com>

From: Huy Nguyen <huyn@mellanox.com>

Add MLX5_SET16 and MLX5_GET16 for 16bit structure field in firmware
command.

Signed-off-by: Huy Nguyen <huyn@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 include/linux/mlx5/device.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 6d79b3f79458..409ffb14298a 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -49,11 +49,15 @@
 #define __mlx5_nullp(typ) ((struct mlx5_ifc_##typ##_bits *)0)
 #define __mlx5_bit_sz(typ, fld) sizeof(__mlx5_nullp(typ)->fld)
 #define __mlx5_bit_off(typ, fld) (offsetof(struct mlx5_ifc_##typ##_bits, fld))
+#define __mlx5_16_off(typ, fld) (__mlx5_bit_off(typ, fld) / 16)
 #define __mlx5_dw_off(typ, fld) (__mlx5_bit_off(typ, fld) / 32)
 #define __mlx5_64_off(typ, fld) (__mlx5_bit_off(typ, fld) / 64)
+#define __mlx5_16_bit_off(typ, fld) (16 - __mlx5_bit_sz(typ, fld) - (__mlx5_bit_off(typ, fld) & 0xf))
 #define __mlx5_dw_bit_off(typ, fld) (32 - __mlx5_bit_sz(typ, fld) - (__mlx5_bit_off(typ, fld) & 0x1f))
 #define __mlx5_mask(typ, fld) ((u32)((1ull << __mlx5_bit_sz(typ, fld)) - 1))
 #define __mlx5_dw_mask(typ, fld) (__mlx5_mask(typ, fld) << __mlx5_dw_bit_off(typ, fld))
+#define __mlx5_mask16(typ, fld) ((u16)((1ull << __mlx5_bit_sz(typ, fld)) - 1))
+#define __mlx5_16_mask(typ, fld) (__mlx5_mask16(typ, fld) << __mlx5_16_bit_off(typ, fld))
 #define __mlx5_st_sz_bits(typ) sizeof(struct mlx5_ifc_##typ##_bits)
 
 #define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
@@ -116,6 +120,19 @@ __mlx5_mask(typ, fld))
 	___t; \
 })
 
+#define MLX5_GET16(typ, p, fld) ((be16_to_cpu(*((__be16 *)(p) +\
+__mlx5_16_off(typ, fld))) >> __mlx5_16_bit_off(typ, fld)) & \
+__mlx5_mask16(typ, fld))
+
+#define MLX5_SET16(typ, p, fld, v) do { \
+	u16 _v = v; \
+	BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 16);             \
+	*((__be16 *)(p) + __mlx5_16_off(typ, fld)) = \
+	cpu_to_be16((be16_to_cpu(*((__be16 *)(p) + __mlx5_16_off(typ, fld))) & \
+		     (~__mlx5_16_mask(typ, fld))) | (((_v) & __mlx5_mask16(typ, fld)) \
+		     << __mlx5_16_bit_off(typ, fld))); \
+} while (0)
+
 /* Big endian getters */
 #define MLX5_GET64_BE(typ, p, fld) (*((__be64 *)(p) +\
 	__mlx5_64_off(typ, fld)))
-- 
2.14.2

  parent reply	other threads:[~2017-11-04  8:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-04  8:50 [pull request][net-next 00/12] Mellanox, mlx5 updates 2017-11-04 Saeed Mahameed
2017-11-04  8:50 ` [net-next 01/12] net/dcb: Add dscp to priority selector type Saeed Mahameed
2017-11-04  8:50 ` [net-next 02/12] net/mlx5: QCAM register firmware command support Saeed Mahameed
2017-11-04  9:04   ` Or Gerlitz
2017-11-04  8:50 ` Saeed Mahameed [this message]
2017-11-04  9:05   ` [net-next 03/12] net/mlx5: Add MLX5_SET16 and MLX5_GET16 Or Gerlitz
2017-11-04  9:35     ` David Miller
2017-11-04 12:55       ` Or Gerlitz
2017-11-05  4:20         ` Saeed Mahameed
2017-11-04  8:50 ` [net-next 04/12] net/mlx5: QPTS and QPDPM register firmware command support Saeed Mahameed
2017-11-04  9:06   ` Or Gerlitz
2017-11-04  8:50 ` [net-next 05/12] net/mlx5e: Add dcbnl dscp to priority support Saeed Mahameed
2017-11-04  8:50 ` [net-next 06/12] net/mlx5e: Support DSCP trust state to Ethernet's IP packet on SQ Saeed Mahameed
2017-11-04  9:07   ` Or Gerlitz
2017-11-04  8:50 ` [net-next 07/12] net/mlx5e: Add support for ethtool msglvl support Saeed Mahameed
2017-11-04  8:50 ` [net-next 08/12] net/mlx5e: DCBNL, Add debug messages log Saeed Mahameed
2017-11-04  8:50 ` [net-next 09/12] net/mlx5: Enlarge the NIC TC offload table size Saeed Mahameed
2017-11-04  8:50 ` [net-next 10/12] net/mlx5: Initialize destination_flow struct to 0 Saeed Mahameed
2017-11-04  8:50 ` [net-next 11/12] net/mlx5e: IPoIB, Add inner TTC table to IPoIB flow steering Saeed Mahameed
2017-11-04  8:50 ` [net-next 12/12] net/mlx5e: Enable CQE based moderation on TX CQ Saeed Mahameed

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=20171104085030.25430-4-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=huyn@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /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.