mbox series

[RDMA,RFC,v6,00/16] Intel RDMA Driver Updates 2020-05-19

Message ID 20200520070415.3392210-1-jeffrey.t.kirsher@intel.com (mailing list archive)
Headers show
Series Intel RDMA Driver Updates 2020-05-19 | expand

Message

Kirsher, Jeffrey T May 20, 2020, 7:03 a.m. UTC
This patch set adds a unified Intel Ethernet Protocol Driver for RDMA that
supports a new network device E810 (iWARP and RoCEv2 capable) and the
existing X722 iWARP device. The driver architecture provides the extensibility
for future generations of Intel HW supporting RDMA.

This driver replaces the legacy X722 driver i40iw and extends the ABI already
defined for i40iw. It is backward compatible with legacy X722 rdma-core
provider (libi40iw).

This series was built against the rdma for-next branch.  This series is
dependant upon the v4 100GbE Intel Wired LAN Driver Updates 2020-05-19
12 patch series, which adds virtual_bus interface and ice/i40e LAN
driver changes.

v5-->v6:
*Convert irdma destroy QP to a synchronous API 
*Drop HMC obj macros for use counts like IRDMA_INC_SD_REFCNT et al.
*cleanup unneccesary 'mem' variable in irdma_create_qp 
*cleanup unused headers such as linux/moduleparam.h et. al 
*set kernel_ver in irdma_ualloc_resp struct to current ABI ver. Placeholder to
 support user-space compatbility checks in future 
*GENMASK/FIELD_PREP scheme to set WQE descriptor fields considered for irdma
 driver but decision to drop. The FIELD_PREP macro cannot be used on the device
 bitfield mask array maintained for common WQE descriptors and initialized
 based on HW generation. The macro expects compile time constants only.
*Use irdma_dbg macro in driver callsites for debug. This macro will use
 ibdev_dbg or dev_dbg depending on ibdevice allocated or not. Other print
 callsites reviewed to use ibdev_* macros wherever possible.
*module alias for i40iw moved to Patch #15 where i40iw driver is removed.
*Misc. driver fixes

v4-->v5:
*Drop driver_data usage from virtbus device id. Use string id match to identify
 virtbus device type.
*Rename device discovery functions
*Drop rdma_set_device_sysfs_group API usage *READ_ONCE annotations for netdev
 flags in rcu_read_lock 

v4:
*Remove redundant explicit casts
*Scrub all WQs to define correct charateristics and use system WQ for reset
 recovery work *Remove all non-functional NULL checks on IDC peer dev OPs 
*Change all pr_* to dev_* if struct device present. Remove dev_info logging 
*Don't use test_bit on non-atomic IIDC_* event types *Remove all module 
 parameters 
*Use bool bitfields in structures instead of bool 
*Change CQP completion handling from kthread to WQ 
*Use the generic devlink parameter enable_roce instead of driver specific one 
*Use meaningful labels for goto unwind *Use new RDMA mmap API 
*Use refcount_t APIs for refcounts on driver objects 
*Add support for ibdev OP dealloc_driver 
*Adapt to use new version of virtbus 
*Remove RCU locking in CM address resolve *Misc. driver fixes

Michael J. Ruhl (1):
  RDMA/irdma: Add dynamic tracing for CM

Mustafa Ismail (13):
  RDMA/irdma: Add driver framework definitions
  RDMA/irdma: Implement device initialization definitions
  RDMA/irdma: Implement HW Admin Queue OPs
  RDMA/irdma: Add HMC backing store setup functions
  RDMA/irdma: Add privileged UDA queue implementation
  RDMA/irdma: Add QoS definitions
  RDMA/irdma: Add connection manager
  RDMA/irdma: Add PBLE resource manager
  RDMA/irdma: Implement device supported verb APIs
  RDMA/irdma: Add RoCEv2 UD OP support
  RDMA/irdma: Add user/kernel shared libraries
  RDMA/irdma: Add miscellaneous utility definitions
  RDMA/irdma: Add ABI definitions

Shiraz Saleem (2):
  RDMA/irdma: Add irdma Kconfig/Makefile and remove i40iw
  RDMA/irdma: Update MAINTAINERS file

 .../ABI/stable/sysfs-class-infiniband         |   18 -
 MAINTAINERS                                   |    8 +-
 drivers/infiniband/Kconfig                    |    2 +-
 drivers/infiniband/hw/Makefile                |    2 +-
 drivers/infiniband/hw/i40iw/Kconfig           |    9 -
 drivers/infiniband/hw/i40iw/Makefile          |    9 -
 drivers/infiniband/hw/i40iw/i40iw.h           |  622 --
 drivers/infiniband/hw/i40iw/i40iw_cm.c        | 4414 ------------
 drivers/infiniband/hw/i40iw/i40iw_cm.h        |  462 --
 drivers/infiniband/hw/i40iw/i40iw_ctrl.c      | 5294 ---------------
 drivers/infiniband/hw/i40iw/i40iw_d.h         | 1757 -----
 drivers/infiniband/hw/i40iw/i40iw_hmc.c       |  821 ---
 drivers/infiniband/hw/i40iw/i40iw_hmc.h       |  241 -
 drivers/infiniband/hw/i40iw/i40iw_hw.c        |  852 ---
 drivers/infiniband/hw/i40iw/i40iw_main.c      | 2070 ------
 drivers/infiniband/hw/i40iw/i40iw_osdep.h     |  217 -
 drivers/infiniband/hw/i40iw/i40iw_p.h         |  129 -
 drivers/infiniband/hw/i40iw/i40iw_pble.c      |  612 --
 drivers/infiniband/hw/i40iw/i40iw_pble.h      |  131 -
 drivers/infiniband/hw/i40iw/i40iw_puda.c      | 1493 ----
 drivers/infiniband/hw/i40iw/i40iw_puda.h      |  188 -
 drivers/infiniband/hw/i40iw/i40iw_register.h  | 1030 ---
 drivers/infiniband/hw/i40iw/i40iw_status.h    |  102 -
 drivers/infiniband/hw/i40iw/i40iw_type.h      | 1375 ----
 drivers/infiniband/hw/i40iw/i40iw_uk.c        | 1232 ----
 drivers/infiniband/hw/i40iw/i40iw_user.h      |  430 --
 drivers/infiniband/hw/i40iw/i40iw_utils.c     | 1557 -----
 drivers/infiniband/hw/i40iw/i40iw_verbs.c     | 2791 --------
 drivers/infiniband/hw/i40iw/i40iw_verbs.h     |  179 -
 drivers/infiniband/hw/i40iw/i40iw_vf.c        |   85 -
 drivers/infiniband/hw/i40iw/i40iw_vf.h        |   62 -
 drivers/infiniband/hw/i40iw/i40iw_virtchnl.c  |  756 ---
 drivers/infiniband/hw/i40iw/i40iw_virtchnl.h  |  124 -
 drivers/infiniband/hw/irdma/Kconfig           |   11 +
 drivers/infiniband/hw/irdma/Makefile          |   28 +
 drivers/infiniband/hw/irdma/cm.c              | 4484 ++++++++++++
 drivers/infiniband/hw/irdma/cm.h              |  417 ++
 drivers/infiniband/hw/irdma/ctrl.c            | 6021 +++++++++++++++++
 drivers/infiniband/hw/irdma/defs.h            | 2167 ++++++
 drivers/infiniband/hw/irdma/hmc.c             |  703 ++
 drivers/infiniband/hw/irdma/hmc.h             |  209 +
 drivers/infiniband/hw/irdma/hw.c              | 2693 ++++++++
 drivers/infiniband/hw/irdma/i40iw_hw.c        |  219 +
 drivers/infiniband/hw/irdma/i40iw_hw.h        |  162 +
 drivers/infiniband/hw/irdma/i40iw_if.c        |  222 +
 drivers/infiniband/hw/irdma/icrdma_hw.c       |   80 +
 drivers/infiniband/hw/irdma/icrdma_hw.h       |   65 +
 drivers/infiniband/hw/irdma/irdma.h           |  193 +
 drivers/infiniband/hw/irdma/irdma_if.c        |  443 ++
 drivers/infiniband/hw/irdma/main.c            |  571 ++
 drivers/infiniband/hw/irdma/main.h            |  612 ++
 drivers/infiniband/hw/irdma/osdep.h           |   98 +
 drivers/infiniband/hw/irdma/pble.c            |  511 ++
 drivers/infiniband/hw/irdma/pble.h            |  136 +
 drivers/infiniband/hw/irdma/protos.h          |  120 +
 drivers/infiniband/hw/irdma/puda.c            | 1739 +++++
 drivers/infiniband/hw/irdma/puda.h            |  187 +
 drivers/infiniband/hw/irdma/status.h          |   69 +
 drivers/infiniband/hw/irdma/trace.c           |  112 +
 drivers/infiniband/hw/irdma/trace.h           |    3 +
 drivers/infiniband/hw/irdma/trace_cm.h        |  458 ++
 drivers/infiniband/hw/irdma/type.h            | 1721 +++++
 drivers/infiniband/hw/irdma/uda.c             |  391 ++
 drivers/infiniband/hw/irdma/uda.h             |   63 +
 drivers/infiniband/hw/irdma/uda_d.h           |  382 ++
 drivers/infiniband/hw/irdma/uk.c              | 1750 +++++
 drivers/infiniband/hw/irdma/user.h            |  448 ++
 drivers/infiniband/hw/irdma/utils.c           | 2437 +++++++
 drivers/infiniband/hw/irdma/verbs.c           | 4566 +++++++++++++
 drivers/infiniband/hw/irdma/verbs.h           |  216 +
 drivers/infiniband/hw/irdma/ws.c              |  393 ++
 drivers/infiniband/hw/irdma/ws.h              |   39 +
 include/uapi/rdma/i40iw-abi.h                 |  107 -
 include/uapi/rdma/ib_user_ioctl_verbs.h       |    1 +
 include/uapi/rdma/irdma-abi.h                 |  140 +
 75 files changed, 35286 insertions(+), 29175 deletions(-)
 delete mode 100644 drivers/infiniband/hw/i40iw/Kconfig
 delete mode 100644 drivers/infiniband/hw/i40iw/Makefile
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_cm.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_cm.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_ctrl.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_d.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_hmc.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_hmc.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_hw.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_main.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_osdep.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_p.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_pble.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_pble.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_puda.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_puda.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_register.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_status.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_type.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_uk.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_user.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_utils.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_verbs.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_verbs.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_vf.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_vf.h
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_virtchnl.c
 delete mode 100644 drivers/infiniband/hw/i40iw/i40iw_virtchnl.h
 create mode 100644 drivers/infiniband/hw/irdma/Kconfig
 create mode 100644 drivers/infiniband/hw/irdma/Makefile
 create mode 100644 drivers/infiniband/hw/irdma/cm.c
 create mode 100644 drivers/infiniband/hw/irdma/cm.h
 create mode 100644 drivers/infiniband/hw/irdma/ctrl.c
 create mode 100644 drivers/infiniband/hw/irdma/defs.h
 create mode 100644 drivers/infiniband/hw/irdma/hmc.c
 create mode 100644 drivers/infiniband/hw/irdma/hmc.h
 create mode 100644 drivers/infiniband/hw/irdma/hw.c
 create mode 100644 drivers/infiniband/hw/irdma/i40iw_hw.c
 create mode 100644 drivers/infiniband/hw/irdma/i40iw_hw.h
 create mode 100644 drivers/infiniband/hw/irdma/i40iw_if.c
 create mode 100644 drivers/infiniband/hw/irdma/icrdma_hw.c
 create mode 100644 drivers/infiniband/hw/irdma/icrdma_hw.h
 create mode 100644 drivers/infiniband/hw/irdma/irdma.h
 create mode 100644 drivers/infiniband/hw/irdma/irdma_if.c
 create mode 100644 drivers/infiniband/hw/irdma/main.c
 create mode 100644 drivers/infiniband/hw/irdma/main.h
 create mode 100644 drivers/infiniband/hw/irdma/osdep.h
 create mode 100644 drivers/infiniband/hw/irdma/pble.c
 create mode 100644 drivers/infiniband/hw/irdma/pble.h
 create mode 100644 drivers/infiniband/hw/irdma/protos.h
 create mode 100644 drivers/infiniband/hw/irdma/puda.c
 create mode 100644 drivers/infiniband/hw/irdma/puda.h
 create mode 100644 drivers/infiniband/hw/irdma/status.h
 create mode 100644 drivers/infiniband/hw/irdma/trace.c
 create mode 100644 drivers/infiniband/hw/irdma/trace.h
 create mode 100644 drivers/infiniband/hw/irdma/trace_cm.h
 create mode 100644 drivers/infiniband/hw/irdma/type.h
 create mode 100644 drivers/infiniband/hw/irdma/uda.c
 create mode 100644 drivers/infiniband/hw/irdma/uda.h
 create mode 100644 drivers/infiniband/hw/irdma/uda_d.h
 create mode 100644 drivers/infiniband/hw/irdma/uk.c
 create mode 100644 drivers/infiniband/hw/irdma/user.h
 create mode 100644 drivers/infiniband/hw/irdma/utils.c
 create mode 100644 drivers/infiniband/hw/irdma/verbs.c
 create mode 100644 drivers/infiniband/hw/irdma/verbs.h
 create mode 100644 drivers/infiniband/hw/irdma/ws.c
 create mode 100644 drivers/infiniband/hw/irdma/ws.h
 delete mode 100644 include/uapi/rdma/i40iw-abi.h
 create mode 100644 include/uapi/rdma/irdma-abi.h

Comments

Jason Gunthorpe May 21, 2020, 2:12 p.m. UTC | #1
On Wed, May 20, 2020 at 12:03:59AM -0700, Jeff Kirsher wrote:
> This patch set adds a unified Intel Ethernet Protocol Driver for RDMA that
> supports a new network device E810 (iWARP and RoCEv2 capable) and the
> existing X722 iWARP device. The driver architecture provides the extensibility
> for future generations of Intel HW supporting RDMA.
> 
> This driver replaces the legacy X722 driver i40iw and extends the ABI already
> defined for i40iw. It is backward compatible with legacy X722 rdma-core
> provider (libi40iw).
> 
> This series was built against the rdma for-next branch.  This series is
> dependant upon the v4 100GbE Intel Wired LAN Driver Updates 2020-05-19
> 12 patch series, which adds virtual_bus interface and ice/i40e LAN
> driver changes.
> 
> v5-->v6:
> *Convert irdma destroy QP to a synchronous API 
> *Drop HMC obj macros for use counts like IRDMA_INC_SD_REFCNT et al.
> *cleanup unneccesary 'mem' variable in irdma_create_qp 
> *cleanup unused headers such as linux/moduleparam.h et. al 
> *set kernel_ver in irdma_ualloc_resp struct to current ABI ver. Placeholder to
>  support user-space compatbility checks in future 
> *GENMASK/FIELD_PREP scheme to set WQE descriptor fields considered for irdma
>  driver but decision to drop. The FIELD_PREP macro cannot be used on the device
>  bitfield mask array maintained for common WQE descriptors and initialized
>  based on HW generation. The macro expects compile time constants
> only.

The request was to use GENMASK for the #define constants. If you move
to a code environment then the spot the constant appears in the C code
should be FIELD_PREP'd into the something dynamic code can use.

Jason
Shiraz Saleem May 27, 2020, 1:58 a.m. UTC | #2
> Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates 2020-05-19
> 
> On Wed, May 20, 2020 at 12:03:59AM -0700, Jeff Kirsher wrote:
> > This patch set adds a unified Intel Ethernet Protocol Driver for RDMA
> > that supports a new network device E810 (iWARP and RoCEv2 capable) and
> > the existing X722 iWARP device. The driver architecture provides the
> > extensibility for future generations of Intel HW supporting RDMA.
> >
> > This driver replaces the legacy X722 driver i40iw and extends the ABI
> > already defined for i40iw. It is backward compatible with legacy X722
> > rdma-core provider (libi40iw).
> >
> > This series was built against the rdma for-next branch.  This series
> > is dependant upon the v4 100GbE Intel Wired LAN Driver Updates
> > 2020-05-19
> > 12 patch series, which adds virtual_bus interface and ice/i40e LAN
> > driver changes.
> >
> > v5-->v6:
> > *Convert irdma destroy QP to a synchronous API *Drop HMC obj macros
> > for use counts like IRDMA_INC_SD_REFCNT et al.
> > *cleanup unneccesary 'mem' variable in irdma_create_qp *cleanup unused
> > headers such as linux/moduleparam.h et. al *set kernel_ver in
> > irdma_ualloc_resp struct to current ABI ver. Placeholder to  support
> > user-space compatbility checks in future *GENMASK/FIELD_PREP scheme to
> > set WQE descriptor fields considered for irdma  driver but decision to
> > drop. The FIELD_PREP macro cannot be used on the device  bitfield mask
> > array maintained for common WQE descriptors and initialized  based on
> > HW generation. The macro expects compile time constants only.
> 
> The request was to use GENMASK for the #define constants. If you move to a
> code environment then the spot the constant appears in the C code should be
> FIELD_PREP'd into the something dynamic code can use.
>

Maybe I am missing something here, but from what I understood,
the vantage point of using GENMASK for the masks
was so that we could get rid of open coding the shift constants and use the
FIELD_PREP macro to place the value in the field of a descriptor.
This should work for the static masks. So something like --

-#define IRDMA_UDA_QPSQ_INLINEDATALEN_S 48
-#define IRDMA_UDA_QPSQ_INLINEDATALEN_M \
-       ((u64)0xff << IRDMA_UDA_QPSQ_INLINEDATALEN_S)
+#define IRDMA_UDA_QPSQ_INLINEDATALEN_M GENMASK_ULL(55, 48)

-#define LS_64(val, field)      (((u64)(val) << field ## _S) & (field ## _M))
+#define LS_64(val, field)      (FIELD_PREP(val,(field ## _M)))

However we have device's dynamically computed bitfield mask array and shifts
for some WQE descriptor fields --
see icrdma_init_hw.c
https://lore.kernel.org/linux-rdma/20200520070415.3392210-3-jeffrey.t.kirsher@intel.com/#Z30drivers:infiniband:hw:irdma:icrdma_hw.c

we still need to use the custom macro FLD_LS_64 without FIELD_PREP in this case
as FIELD_PREP expects compile time constants.
+#define FLD_LS_64(dev, val, field)	\
+	(((u64)(val) << (dev)->hw_shifts[field ## _S]) & (dev)->hw_masks[field 
+## _M])
And the shifts are still required for these fields which causes a bit of
inconsistency
Leon Romanovsky May 27, 2020, 5:08 a.m. UTC | #3
On Wed, May 27, 2020 at 01:58:01AM +0000, Saleem, Shiraz wrote:
> > Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates 2020-05-19
> >
> > On Wed, May 20, 2020 at 12:03:59AM -0700, Jeff Kirsher wrote:
> > > This patch set adds a unified Intel Ethernet Protocol Driver for RDMA
> > > that supports a new network device E810 (iWARP and RoCEv2 capable) and
> > > the existing X722 iWARP device. The driver architecture provides the
> > > extensibility for future generations of Intel HW supporting RDMA.
> > >
> > > This driver replaces the legacy X722 driver i40iw and extends the ABI
> > > already defined for i40iw. It is backward compatible with legacy X722
> > > rdma-core provider (libi40iw).
> > >
> > > This series was built against the rdma for-next branch.  This series
> > > is dependant upon the v4 100GbE Intel Wired LAN Driver Updates
> > > 2020-05-19
> > > 12 patch series, which adds virtual_bus interface and ice/i40e LAN
> > > driver changes.
> > >
> > > v5-->v6:
> > > *Convert irdma destroy QP to a synchronous API *Drop HMC obj macros
> > > for use counts like IRDMA_INC_SD_REFCNT et al.
> > > *cleanup unneccesary 'mem' variable in irdma_create_qp *cleanup unused
> > > headers such as linux/moduleparam.h et. al *set kernel_ver in
> > > irdma_ualloc_resp struct to current ABI ver. Placeholder to  support
> > > user-space compatbility checks in future *GENMASK/FIELD_PREP scheme to
> > > set WQE descriptor fields considered for irdma  driver but decision to
> > > drop. The FIELD_PREP macro cannot be used on the device  bitfield mask
> > > array maintained for common WQE descriptors and initialized  based on
> > > HW generation. The macro expects compile time constants only.
> >
> > The request was to use GENMASK for the #define constants. If you move to a
> > code environment then the spot the constant appears in the C code should be
> > FIELD_PREP'd into the something dynamic code can use.
> >
>
> Maybe I am missing something here, but from what I understood,
> the vantage point of using GENMASK for the masks
> was so that we could get rid of open coding the shift constants and use the
> FIELD_PREP macro to place the value in the field of a descriptor.
> This should work for the static masks. So something like --
>
> -#define IRDMA_UDA_QPSQ_INLINEDATALEN_S 48
> -#define IRDMA_UDA_QPSQ_INLINEDATALEN_M \
> -       ((u64)0xff << IRDMA_UDA_QPSQ_INLINEDATALEN_S)
> +#define IRDMA_UDA_QPSQ_INLINEDATALEN_M GENMASK_ULL(55, 48)
>
> -#define LS_64(val, field)      (((u64)(val) << field ## _S) & (field ## _M))
> +#define LS_64(val, field)      (FIELD_PREP(val,(field ## _M)))
                                                         ^^^^ it is not needed anymore
>
> However we have device's dynamically computed bitfield mask array and shifts
> for some WQE descriptor fields --
> see icrdma_init_hw.c
> https://lore.kernel.org/linux-rdma/20200520070415.3392210-3-jeffrey.t.kirsher@intel.com/#Z30drivers:infiniband:hw:irdma:icrdma_hw.c

I'm looking on it and see static assignments, to by dynamic you will need
"to play" with hw_shifts/hw_masks later, but you don't. What am I missing?

+	for (i = 0; i < IRDMA_MAX_SHIFTS; ++i)
+		dev->hw_shifts[i] = i40iw_shifts[i];
+
+	for (i = 0; i < IRDMA_MAX_MASKS; ++i)
+		dev->hw_masks[i] = i40iw_masks[i];

>
> we still need to use the custom macro FLD_LS_64 without FIELD_PREP in this case
> as FIELD_PREP expects compile time constants.
> +#define FLD_LS_64(dev, val, field)	\
> +	(((u64)(val) << (dev)->hw_shifts[field ## _S]) & (dev)->hw_masks[field
> +## _M])
> And the shifts are still required for these fields which causes a bit of
> inconsistency
>
>
>
Shiraz Saleem May 29, 2020, 3:21 p.m. UTC | #4
> Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates 2020-05-19
> 

[......]

> 
> I'm looking on it and see static assignments, to by dynamic you will need "to play"
> with hw_shifts/hw_masks later, but you don't. What am I missing?
> 
> +	for (i = 0; i < IRDMA_MAX_SHIFTS; ++i)
> +		dev->hw_shifts[i] = i40iw_shifts[i];
> +
> +	for (i = 0; i < IRDMA_MAX_MASKS; ++i)
> +		dev->hw_masks[i] = i40iw_masks[i];
> 
> >
> > we still need to use the custom macro FLD_LS_64 without FIELD_PREP in
> > this case as FIELD_PREP expects compile time constants.
> > +#define FLD_LS_64(dev, val, field)	\
> > +	(((u64)(val) << (dev)->hw_shifts[field ## _S]) &
> > +(dev)->hw_masks[field ## _M])
> > And the shifts are still required for these fields which causes a bit
> > of inconsistency
> >


The device hw_masks/hw_shifts array store masks/shifts of those
descriptor fields that have same name across HW generations but
differ in some attribute such as field width. Yes they are statically assigned,
initialized with values from i40iw_masks and icrdma_masks, depending on
the HW generation. We can even use GENMASK for the values in
i40iw_masks[] , icrdma_masks[] but FIELD_PREP cant be used on
dev->hw_masks[]
Jason Gunthorpe June 1, 2020, 2:28 p.m. UTC | #5
On Fri, May 29, 2020 at 03:21:05PM +0000, Saleem, Shiraz wrote:
> > Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates 2020-05-19
> > 
> 
> [......]
> 
> > 
> > I'm looking on it and see static assignments, to by dynamic you will need "to play"
> > with hw_shifts/hw_masks later, but you don't. What am I missing?
> > 
> > +	for (i = 0; i < IRDMA_MAX_SHIFTS; ++i)
> > +		dev->hw_shifts[i] = i40iw_shifts[i];
> > +
> > +	for (i = 0; i < IRDMA_MAX_MASKS; ++i)
> > +		dev->hw_masks[i] = i40iw_masks[i];
> > 
> > >
> > > we still need to use the custom macro FLD_LS_64 without FIELD_PREP in
> > > this case as FIELD_PREP expects compile time constants.
> > > +#define FLD_LS_64(dev, val, field)	\
> > > +	(((u64)(val) << (dev)->hw_shifts[field ## _S]) &
> > > +(dev)->hw_masks[field ## _M])
> > > And the shifts are still required for these fields which causes a bit
> > > of inconsistency
> > >
> 
> 
> The device hw_masks/hw_shifts array store masks/shifts of those
> descriptor fields that have same name across HW generations but
> differ in some attribute such as field width. Yes they are statically assigned,
> initialized with values from i40iw_masks and icrdma_masks, depending on
> the HW generation. We can even use GENMASK for the values in
> i40iw_masks[] , icrdma_masks[] but FIELD_PREP cant be used on
> dev->hw_masks[]

So compute the shift and mask when building i40iw_shifts array using
the compile time constant?

Jason
Shiraz Saleem June 2, 2020, 10:59 p.m. UTC | #6
> Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates 2020-05-19
> 
> On Fri, May 29, 2020 at 03:21:05PM +0000, Saleem, Shiraz wrote:
> > > Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates
> > > 2020-05-19
> > >
> >
> > [......]
> >
> > >
> > > I'm looking on it and see static assignments, to by dynamic you will need "to
> play"
> > > with hw_shifts/hw_masks later, but you don't. What am I missing?
> > >
> > > +	for (i = 0; i < IRDMA_MAX_SHIFTS; ++i)
> > > +		dev->hw_shifts[i] = i40iw_shifts[i];
> > > +
> > > +	for (i = 0; i < IRDMA_MAX_MASKS; ++i)
> > > +		dev->hw_masks[i] = i40iw_masks[i];
> > >
> > > >
> > > > we still need to use the custom macro FLD_LS_64 without FIELD_PREP
> > > > in this case as FIELD_PREP expects compile time constants.
> > > > +#define FLD_LS_64(dev, val, field)	\
> > > > +	(((u64)(val) << (dev)->hw_shifts[field ## _S]) &
> > > > +(dev)->hw_masks[field ## _M])
> > > > And the shifts are still required for these fields which causes a
> > > > bit of inconsistency
> > > >
> >
> >
> > The device hw_masks/hw_shifts array store masks/shifts of those
> > descriptor fields that have same name across HW generations but differ
> > in some attribute such as field width. Yes they are statically
> > assigned, initialized with values from i40iw_masks and icrdma_masks,
> > depending on the HW generation. We can even use GENMASK for the values
> > in i40iw_masks[] , icrdma_masks[] but FIELD_PREP cant be used on
> > dev->hw_masks[]
> 
> So compute the shift and mask when building i40iw_shifts array using the compile
> time constant?
> 

i40iw_shifts[] and i40iw_mask[] are setup as compile constants
and used to initialize dev->hw_masks[], dev->hw_shifts[] if the device is gen1.
I still don't see how FIELD_PREP can be used on a value and
dev->hw_masks[i].
Jason Gunthorpe June 2, 2020, 11:29 p.m. UTC | #7
On Tue, Jun 02, 2020 at 10:59:46PM +0000, Saleem, Shiraz wrote:
> > Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates 2020-05-19
> > 
> > On Fri, May 29, 2020 at 03:21:05PM +0000, Saleem, Shiraz wrote:
> > > > Subject: Re: [RDMA RFC v6 00/16] Intel RDMA Driver Updates
> > > > 2020-05-19
> > > >
> > >
> > > [......]
> > >
> > > >
> > > > I'm looking on it and see static assignments, to by dynamic you will need "to
> > play"
> > > > with hw_shifts/hw_masks later, but you don't. What am I missing?
> > > >
> > > > +	for (i = 0; i < IRDMA_MAX_SHIFTS; ++i)
> > > > +		dev->hw_shifts[i] = i40iw_shifts[i];
> > > > +
> > > > +	for (i = 0; i < IRDMA_MAX_MASKS; ++i)
> > > > +		dev->hw_masks[i] = i40iw_masks[i];
> > > >
> > > > >
> > > > > we still need to use the custom macro FLD_LS_64 without FIELD_PREP
> > > > > in this case as FIELD_PREP expects compile time constants.
> > > > > +#define FLD_LS_64(dev, val, field)	\
> > > > > +	(((u64)(val) << (dev)->hw_shifts[field ## _S]) &
> > > > > +(dev)->hw_masks[field ## _M])
> > > > > And the shifts are still required for these fields which causes a
> > > > > bit of inconsistency
> > > > >
> > >
> > >
> > > The device hw_masks/hw_shifts array store masks/shifts of those
> > > descriptor fields that have same name across HW generations but differ
> > > in some attribute such as field width. Yes they are statically
> > > assigned, initialized with values from i40iw_masks and icrdma_masks,
> > > depending on the HW generation. We can even use GENMASK for the values
> > > in i40iw_masks[] , icrdma_masks[] but FIELD_PREP cant be used on
> > > dev->hw_masks[]
> > 
> > So compute the shift and mask when building i40iw_shifts array using the compile
> > time constant?
> > 
> 
> i40iw_shifts[] and i40iw_mask[] are setup as compile constants
> and used to initialize dev->hw_masks[], dev->hw_shifts[] if the device is gen1.
> I still don't see how FIELD_PREP can be used on a value and
> dev->hw_masks[i].

Well, you can't, you'd still have to use this indirection, the point
was to make the #define macros consistent 

Jason