STRUCT KS8851_NET(9)
β¨ struct ks8851_net(9) β the KS8851 driver's private data π
okay so this is a page from the Kernel API Manual, and honestly? it's the whole private-data glow-up for the KS8851 driver. every field, every callback, every cached register copy β it's all here. let's get into it π
πΈ SYNOPSIS πΈ
struct ks8851_net {
struct net_device *netdev;
spinlock_t statelock;
union ks8851_tx_hdr txh;
u8 rxd[8];
u8 txd[8];
u32 msg_enable;
u16 tx_space;
u8 fid;
u16 rc_ier;
u16 rc_rxqcr;
u16 rc_ccr;
struct mii_if_info mii;
struct ks8851_rxctrl rxctrl;
struct work_struct rxctrl_work;
struct sk_buff_head txq;
unsigned int queued_len;
struct eeprom_93cx6 eeprom;
struct regulator *vdd_reg;
struct regulator *vdd_io;
struct gpio_desc *gpio;
struct mii_bus *mii_bus;
void (*lock)(struct ks8851_net *ks);
void (*unlock)(struct ks8851_net *ks);
unsigned int (*rdreg16)(struct ks8851_net *ks, unsigned int reg);
void (*wrreg16)(struct ks8851_net *ks, unsigned int reg, unsigned int val);
void (*rdfifo)(struct ks8851_net *ks, u8 *buff, unsigned int len);
void (*wrfifo)(struct ks8851_net *ks, struct sk_buff *txp, bool irq);
netdev_tx_t (*start_xmit)(struct sk_buff *skb, struct net_device *dev);
void (*flush_tx_work)(struct ks8851_net *ks);
};
like, look at all those function pointers. she's literally a vtable with a netdev attached π¦
π Members π
no skipping, bestie β every single one:
netdevβ the network device we're bound to. our main character π₯statelockβ lock on this structure for tx list.txhβ space for generating packet TX header in DMA-able data.rxdβ space for receiving SPI data, in DMA-able space.txdβ space for transmitting SPI data, in DMA-able space.msg_enableβ the message flags controlling driver output (see ethtool).tx_spaceβ free space in the hardware TX buffer (cached copy ofKS_TXMIR).fidβ incrementing frame id tag.rc_ierβ cached copy ofKS_IER.rc_rxqcrβ cached copy ofKS_RXQCR.rc_ccrβ cached copy ofKS_CCR.miiβ the MII state information for the mii calls.rxctrlβ RX settings forrxctrl_work.rxctrl_workβ work queue for updating RX mode and multicast lists.txqβ queue of packets for transmission.queued_lenβ space required in hardware TX buffer for queued packets intxq.eepromβ 93CX6 EEPROM state for accessing on-board EEPROM.vdd_regβ optional regulator supplying the chip.vdd_ioβ optional digital power supply for IO.gpioβ optionalreset_ngpio.mii_busβ pointer to MII bus structure.lockβ bus access lock callback.unlockβ bus access unlock callback.rdreg16β 16bit register read callback.wrreg16β 16bit register write callback.rdfifoβ FIFO read callback.wrfifoβ FIFO write callback.start_xmitβstart_xmitimplementation callback.flush_tx_workβflush_tx_workimplementation callback.
π«Ά Description π«Ά
so statelock is doing the whole bodyguard thing π
β it protects information in the structure which may need to be accessed via several sources, such as the network driver layer or one of the work queues. multi-source access? she's got it handled, no cap.
and we align the buffers we may use for rx/tx to ensure that if the SPI driver wants to DMA map them, it will not have any problems with data the driver modifies. alignment era β¨ like yes, respect the DMA mapping, it's the bare minimum.
π SEE ALSO π
- Kernel file
./drivers/net/ethernet/micrel/ks8851.h struct ks8851_rxctrl(9)union ks8851_tx_hdr(9)ks8851_done_tx(9)
okay that's the whole vibe check, you now know every field in struct ks8851_net fr fr π§π courtesy of the source dir ./drivers/net/ethernet/micrel, dated October 2026, page struct ks8851_net(9) β go forth and slay your networking bugs, bestie πβ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms