Skip to content

Commit

Permalink
inline ddi_{get,put} wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
danmcd committed Sep 28, 2023
1 parent e567e45 commit 221fc46
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 66 deletions.
61 changes: 3 additions & 58 deletions usr/src/uts/common/io/mlxcx/mlxcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,9 @@ mlxcx_load_props(mlxcx_t *mlxp)
p->mldp_rx_per_cq = MLXCX_RX_PER_CQ_DEFAULT;
}

p->mldp_rx_p50_loan_min_size = ddi_getprop(DDI_DEV_T_ANY,
mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS,
"rx_p50_loan_min_size", MLXCX_P50_LOAN_MIN_SIZE_DFLT);
p->mldp_rx_p50_loan_min_size = ddi_getprop(DDI_DEV_T_ANY,
mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS,
"rx_p50_loan_min_size", MLXCX_P50_LOAN_MIN_SIZE_DFLT);
}

void
Expand Down Expand Up @@ -653,61 +653,6 @@ mlxcx_panic(mlxcx_t *mlxp, const char *fmt, ...)
va_end(ap);
}

uint16_t
mlxcx_get16(mlxcx_t *mlxp, uintptr_t off)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
return (ddi_get16(mlxp->mlx_regs_handle, (void *)addr));
}

uint32_t
mlxcx_get32(mlxcx_t *mlxp, uintptr_t off)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
return (ddi_get32(mlxp->mlx_regs_handle, (void *)addr));
}

uint64_t
mlxcx_get64(mlxcx_t *mlxp, uintptr_t off)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
return (ddi_get64(mlxp->mlx_regs_handle, (void *)addr));
}

void
mlxcx_put32(mlxcx_t *mlxp, uintptr_t off, uint32_t val)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
}

void
mlxcx_put64(mlxcx_t *mlxp, uintptr_t off, uint64_t val)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
}

void
mlxcx_uar_put32(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint32_t val)
{
/*
* The UAR is always inside the first BAR, which we mapped as
* mlx_regs
*/
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
(uintptr_t)mlxp->mlx_regs_base;
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
}

void
mlxcx_uar_put64(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint64_t val)
{
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
(uintptr_t)mlxp->mlx_regs_base;
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
}

static void
mlxcx_fm_fini(mlxcx_t *mlxp)
{
Expand Down
61 changes: 53 additions & 8 deletions usr/src/uts/common/io/mlxcx/mlxcx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1202,17 +1202,62 @@ struct mlxcx {
};

/*
* Register access
* Register access. Use static inlines.
*/
extern uint16_t mlxcx_get16(mlxcx_t *, uintptr_t);
extern uint32_t mlxcx_get32(mlxcx_t *, uintptr_t);
extern uint64_t mlxcx_get64(mlxcx_t *, uintptr_t);
static inline uint16_t
mlxcx_get16(mlxcx_t *mlxp, uintptr_t off)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
return (ddi_get16(mlxp->mlx_regs_handle, (void *)addr));
}

static inline uint32_t
mlxcx_get32(mlxcx_t *mlxp, uintptr_t off)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
return (ddi_get32(mlxp->mlx_regs_handle, (void *)addr));
}

static inline uint64_t
mlxcx_get64(mlxcx_t *mlxp, uintptr_t off)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
return (ddi_get64(mlxp->mlx_regs_handle, (void *)addr));
}

static inline void
mlxcx_put32(mlxcx_t *mlxp, uintptr_t off, uint32_t val)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
}

extern void mlxcx_put32(mlxcx_t *, uintptr_t, uint32_t);
extern void mlxcx_put64(mlxcx_t *, uintptr_t, uint64_t);
static inline void
mlxcx_put64(mlxcx_t *mlxp, uintptr_t off, uint64_t val)
{
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
}

static inline void
mlxcx_uar_put32(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint32_t val)
{
/*
* The UAR is always inside the first BAR, which we mapped as
* mlx_regs
*/
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
(uintptr_t)mlxp->mlx_regs_base;
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
}

extern void mlxcx_uar_put32(mlxcx_t *, mlxcx_uar_t *, uintptr_t, uint32_t);
extern void mlxcx_uar_put64(mlxcx_t *, mlxcx_uar_t *, uintptr_t, uint64_t);
static inline void
mlxcx_uar_put64(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint64_t val)
{
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
(uintptr_t)mlxp->mlx_regs_base;
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
}

/*
* Logging functions.
Expand Down

0 comments on commit 221fc46

Please sign in to comment.