STRUCT KS8851_NET(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 of KS_TXMIR).
  • fid β€” incrementing frame id tag.
  • rc_ier β€” cached copy of KS_IER.
  • rc_rxqcr β€” cached copy of KS_RXQCR.
  • rc_ccr β€” cached copy of KS_CCR.
  • mii β€” the MII state information for the mii calls.
  • rxctrl β€” RX settings for rxctrl_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 in txq.
  • 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 β€” optional reset_n gpio.
  • 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_xmit implementation callback.
  • flush_tx_work β€” flush_tx_work implementation 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