Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a29cc40 authored by Ben Hutchings's avatar Ben Hutchings
Browse files

sfc: Add compile-time checks for correctness of paged register writes

parent 494bdf1b
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -226,26 +226,37 @@ static inline void efx_readd_table(struct efx_nic *efx, efx_dword_t *value,
	((page) * EFX_PAGE_BLOCK_SIZE + (reg))

/* Write the whole of RX_DESC_UPD or TX_DESC_UPD */
static inline void efx_writeo_page(struct efx_nic *efx, efx_oword_t *value,
static inline void _efx_writeo_page(struct efx_nic *efx, efx_oword_t *value,
				    unsigned int reg, unsigned int page)
{
	efx_writeo(efx, value, EFX_PAGED_REG(page, reg));
}
#define efx_writeo_page(efx, value, reg, page)				\
	_efx_writeo_page(efx, value,					\
			 reg +						\
			 BUILD_BUG_ON_ZERO((reg) != 0x830 && (reg) != 0xa10), \
			 page)

/* Write a page-mapped 32-bit CSR (EVQ_RPTR or the high bits of
 * RX_DESC_UPD or TX_DESC_UPD)
 */
static inline void efx_writed_page(struct efx_nic *efx, efx_dword_t *value,
static inline void _efx_writed_page(struct efx_nic *efx, efx_dword_t *value,
				    unsigned int reg, unsigned int page)
{
	efx_writed(efx, value, EFX_PAGED_REG(page, reg));
}
#define efx_writed_page(efx, value, reg, page)				\
	_efx_writed_page(efx, value,					\
			 reg +						\
			 BUILD_BUG_ON_ZERO((reg) != 0x400 && (reg) != 0x83c \
					   && (reg) != 0xa1c),		\
			 page)

/* Write TIMER_COMMAND.  This is a page-mapped 32-bit CSR, but a bug
 * in the BIU means that writes to TIMER_COMMAND[0] invalidate the
 * collector register.
 */
static inline void efx_writed_page_locked(struct efx_nic *efx,
static inline void _efx_writed_page_locked(struct efx_nic *efx,
					   efx_dword_t *value,
					   unsigned int reg,
					   unsigned int page)
@@ -260,5 +271,9 @@ static inline void efx_writed_page_locked(struct efx_nic *efx,
		efx_writed(efx, value, EFX_PAGED_REG(page, reg));
	}
}
#define efx_writed_page_locked(efx, value, reg, page)			\
	_efx_writed_page_locked(efx, value,				\
				reg + BUILD_BUG_ON_ZERO((reg) != 0x420), \
				page)

#endif /* EFX_IO_H */