drivers/net/ethernet/freescale/enetc/enetc_hw.h

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/enetc/enetc_hw.h

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/freescale/enetc/enetc_hw.h
Extension
.h
Size
31077 bytes
Lines
1061
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct enetc_hw {
	/* SI registers, used by all PCI functions */
	void __iomem *reg;
	/* Port registers, PF only */
	void __iomem *port;
	/* IP global registers, PF only */
	void __iomem *global;
};

/* ENETC register accessors */

/* MDIO issue workaround (on LS1028A) -
 * Due to a hardware issue, an access to MDIO registers
 * that is concurrent with other ENETC register accesses
 * may lead to the MDIO access being dropped or corrupted.
 * To protect the MDIO accesses a readers-writers locking
 * scheme is used, where the MDIO register accesses are
 * protected by write locks to insure exclusivity, while
 * the remaining ENETC registers are accessed under read
 * locks since they only compete with MDIO accesses.
 */
extern rwlock_t enetc_mdio_lock;

DECLARE_STATIC_KEY_FALSE(enetc_has_err050089);

/* use this locking primitive only on the fast datapath to
 * group together multiple non-MDIO register accesses to
 * minimize the overhead of the lock
 */
static inline void enetc_lock_mdio(void)
{
	if (static_branch_unlikely(&enetc_has_err050089))
		read_lock(&enetc_mdio_lock);
}

static inline void enetc_unlock_mdio(void)
{
	if (static_branch_unlikely(&enetc_has_err050089))
		read_unlock(&enetc_mdio_lock);
}

/* use these accessors only on the fast datapath under
 * the enetc_lock_mdio() locking primitive to minimize
 * the overhead of the lock
 */
static inline u32 enetc_rd_reg_hot(void __iomem *reg)
{
	if (static_branch_unlikely(&enetc_has_err050089))
		lockdep_assert_held(&enetc_mdio_lock);

	return ioread32(reg);
}

static inline void enetc_wr_reg_hot(void __iomem *reg, u32 val)
{
	if (static_branch_unlikely(&enetc_has_err050089))
		lockdep_assert_held(&enetc_mdio_lock);

	iowrite32(val, reg);
}

/* internal helpers for the MDIO w/a */
static inline u32 _enetc_rd_reg_wa(void __iomem *reg)
{
	u32 val;

	enetc_lock_mdio();
	val = ioread32(reg);
	enetc_unlock_mdio();

	return val;
}

static inline void _enetc_wr_reg_wa(void __iomem *reg, u32 val)
{
	enetc_lock_mdio();
	iowrite32(val, reg);
	enetc_unlock_mdio();
}

static inline u32 _enetc_rd_mdio_reg_wa(void __iomem *reg)
{
	unsigned long flags;
	u32 val;

	if (static_branch_unlikely(&enetc_has_err050089)) {
		write_lock_irqsave(&enetc_mdio_lock, flags);
		val = ioread32(reg);
		write_unlock_irqrestore(&enetc_mdio_lock, flags);
	} else {

Annotation

Implementation Notes