Skip to content

Commit 221fc46

Browse files
committed
inline ddi_{get,put} wrappers
1 parent e567e45 commit 221fc46

File tree

2 files changed

+56
-66
lines changed

2 files changed

+56
-66
lines changed

usr/src/uts/common/io/mlxcx/mlxcx.c

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,9 @@ mlxcx_load_props(mlxcx_t *mlxp)
606606
p->mldp_rx_per_cq = MLXCX_RX_PER_CQ_DEFAULT;
607607
}
608608

609-
p->mldp_rx_p50_loan_min_size = ddi_getprop(DDI_DEV_T_ANY,
610-
mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS,
611-
"rx_p50_loan_min_size", MLXCX_P50_LOAN_MIN_SIZE_DFLT);
609+
p->mldp_rx_p50_loan_min_size = ddi_getprop(DDI_DEV_T_ANY,
610+
mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS,
611+
"rx_p50_loan_min_size", MLXCX_P50_LOAN_MIN_SIZE_DFLT);
612612
}
613613

614614
void
@@ -653,61 +653,6 @@ mlxcx_panic(mlxcx_t *mlxp, const char *fmt, ...)
653653
va_end(ap);
654654
}
655655

656-
uint16_t
657-
mlxcx_get16(mlxcx_t *mlxp, uintptr_t off)
658-
{
659-
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
660-
return (ddi_get16(mlxp->mlx_regs_handle, (void *)addr));
661-
}
662-
663-
uint32_t
664-
mlxcx_get32(mlxcx_t *mlxp, uintptr_t off)
665-
{
666-
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
667-
return (ddi_get32(mlxp->mlx_regs_handle, (void *)addr));
668-
}
669-
670-
uint64_t
671-
mlxcx_get64(mlxcx_t *mlxp, uintptr_t off)
672-
{
673-
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
674-
return (ddi_get64(mlxp->mlx_regs_handle, (void *)addr));
675-
}
676-
677-
void
678-
mlxcx_put32(mlxcx_t *mlxp, uintptr_t off, uint32_t val)
679-
{
680-
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
681-
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
682-
}
683-
684-
void
685-
mlxcx_put64(mlxcx_t *mlxp, uintptr_t off, uint64_t val)
686-
{
687-
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
688-
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
689-
}
690-
691-
void
692-
mlxcx_uar_put32(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint32_t val)
693-
{
694-
/*
695-
* The UAR is always inside the first BAR, which we mapped as
696-
* mlx_regs
697-
*/
698-
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
699-
(uintptr_t)mlxp->mlx_regs_base;
700-
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
701-
}
702-
703-
void
704-
mlxcx_uar_put64(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint64_t val)
705-
{
706-
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
707-
(uintptr_t)mlxp->mlx_regs_base;
708-
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
709-
}
710-
711656
static void
712657
mlxcx_fm_fini(mlxcx_t *mlxp)
713658
{

usr/src/uts/common/io/mlxcx/mlxcx.h

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,17 +1202,62 @@ struct mlxcx {
12021202
};
12031203

12041204
/*
1205-
* Register access
1205+
* Register access. Use static inlines.
12061206
*/
1207-
extern uint16_t mlxcx_get16(mlxcx_t *, uintptr_t);
1208-
extern uint32_t mlxcx_get32(mlxcx_t *, uintptr_t);
1209-
extern uint64_t mlxcx_get64(mlxcx_t *, uintptr_t);
1207+
static inline uint16_t
1208+
mlxcx_get16(mlxcx_t *mlxp, uintptr_t off)
1209+
{
1210+
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
1211+
return (ddi_get16(mlxp->mlx_regs_handle, (void *)addr));
1212+
}
1213+
1214+
static inline uint32_t
1215+
mlxcx_get32(mlxcx_t *mlxp, uintptr_t off)
1216+
{
1217+
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
1218+
return (ddi_get32(mlxp->mlx_regs_handle, (void *)addr));
1219+
}
1220+
1221+
static inline uint64_t
1222+
mlxcx_get64(mlxcx_t *mlxp, uintptr_t off)
1223+
{
1224+
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
1225+
return (ddi_get64(mlxp->mlx_regs_handle, (void *)addr));
1226+
}
1227+
1228+
static inline void
1229+
mlxcx_put32(mlxcx_t *mlxp, uintptr_t off, uint32_t val)
1230+
{
1231+
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
1232+
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
1233+
}
12101234

1211-
extern void mlxcx_put32(mlxcx_t *, uintptr_t, uint32_t);
1212-
extern void mlxcx_put64(mlxcx_t *, uintptr_t, uint64_t);
1235+
static inline void
1236+
mlxcx_put64(mlxcx_t *mlxp, uintptr_t off, uint64_t val)
1237+
{
1238+
uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base;
1239+
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
1240+
}
1241+
1242+
static inline void
1243+
mlxcx_uar_put32(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint32_t val)
1244+
{
1245+
/*
1246+
* The UAR is always inside the first BAR, which we mapped as
1247+
* mlx_regs
1248+
*/
1249+
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
1250+
(uintptr_t)mlxp->mlx_regs_base;
1251+
ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val);
1252+
}
12131253

1214-
extern void mlxcx_uar_put32(mlxcx_t *, mlxcx_uar_t *, uintptr_t, uint32_t);
1215-
extern void mlxcx_uar_put64(mlxcx_t *, mlxcx_uar_t *, uintptr_t, uint64_t);
1254+
static inline void
1255+
mlxcx_uar_put64(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint64_t val)
1256+
{
1257+
uintptr_t addr = off + (uintptr_t)mlu->mlu_base +
1258+
(uintptr_t)mlxp->mlx_regs_base;
1259+
ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val);
1260+
}
12161261

12171262
/*
12181263
* Logging functions.

0 commit comments

Comments
 (0)