HDLCDRV(9)
π HDLCDRV(9) π
okay so bestie, welcome to the manual page for hdlcdrv β the HDLC amateur (AX.25) packet radio network driver, and yes we're doing this properly, from the Kernel Reference Guide, no cap. Grab a snack, this one's a whole vibe π
β¨ NAME β¨
hdlcdrv β the HDLC amateur (AX.25) packet radio network driver. that's it, that's the name, and honestly it ate π
π¦ SYNOPSIS π¦
#include <linux/hdlcdrv.h>
linux/drivers/net/hdlcdrv.c
extern inline void hdlcdrv_putbits(struct hdlcdrv_state * s, unsigned
int bits);
extern inline unsigned int hdlcdrv_getbits(struct hdlcdrv_state * s);
extern inline void hdlcdrv_channelbit(struct hdlcdrv_state * s, unsigned
int bit);
extern inline void hdlcdrv_setdcd(struct hdlcdrv_state * s , int dcd);
extern inline int hdlcdrv_ptt(struct hdlcdrv_state * s);
void hdlcdrv_receiver(struct device *, struct hdlcdrv_state *);
void hdlcdrv_transmitter(struct device *, struct hdlcdrv_state *);
void hdlcdrv_arbitrate(struct device *, struct hdlcdrv_state *);
int hdlcdrv_register_hdlcdrv(struct device * dev, struct hdlcdrv_ops *
ops, unsigned int privsize, char * ifname, unsigned int baseaddr ,
unsigned int irq, unsigned int dma);
int hdlcdrv_unregister_hdlcdrv(struct device * dev);
like, look at all those little functions. iconic. π
πΈ DESCRIPTION πΈ
so the whole point of this driver is that it eases the implementation of simple AX.25 packet radio modems where the software is the one doing the HDLC encoding and decoding. examples of such modems include the baycom family and the soundcard modems β iykyk π
this driver gives you a standard Linux network driver interface. and the wild part? it can even be compiled if Kernel AX.25 is not enabled in the Linux configuration. that means this driver can be used even for userland AX.25 stacks such as Wampes or TNOS, with a little help from the net2kiss utility. slay. β¨
π«Ά important: this driver does not access any hardware. it is the responsibility of an additional hardware driver β such asbaycomorsoundmodemβ to access the hardware and derive the bitstream to feed into this driver. division of labor, main character energy.
π§ the state struct
the hardware driver should store its state in a structure of the following form:
struct hwdrv_state {
struct hdlc_state hdrv;
... the drivers private state
};
a pointer to this structure will be stored in dev->priv. noted. π
π the functions, one by one
hdlcdrv_register_hdlcdrv registers a hardware driver to the hdlc driver. dev points to storage for the device structure β which must be provided by the hardware driver, but gets initialized by this function call. ops provides information about the hardware driver and its calls. privsize should be sizeof(struct hwdrv_state). ifname specifies the name the interface should get. baseaddr, irq and dma are simply stored in the device structure. after this function succeeds, the interface is registered with the kernel. it is not running, however β you gotta do that yourself with ifconfig ifname up. π₯
hdlcdrv_unregister_hdlcdrv shuts the interface down and unregisters it with the kernel. bye bestie π
hdlcdrv_putbits delivers 16 received bits for processing to the HDLC driver. this routine merely stores them in a buffer and does not process them. it is thus fast and can be called with interrupts off. the least significant bit should be the first one received. β
hdlcdrv_getbits requests 16 bits from the driver for transmission. the least significant bit should be transmitted first. this routine takes them from a buffer and is therefore fast. it can be called with interrupts off. π¦
hdlcdrv_channelbit puts a single bit into a buffer, which can be displayed with sethdlc -s. it is intended for driver debugging purposes. π
hdlcdrv_setdcd informs the HDLC driver about the channel state (i.e. if the hardware driver detected a data carrier). this information is used in the channel access algorithm β i.e. it prevents the driver from transmitting on a half duplex channel if there is already a transmitter on air. courtesy, we love to see it π
hdlcdrv_ptt should be called by the hardware driver to determine if it should start or stop transmitting. the hardware driver does not need to worry about keyup delays β this is done by the HDLC driver. we handle that for you, bestie π«Ά
hdlcdrv_receiver actually processes the received bits delivered by hdlcdrv_putbits. it should be called with interrupts on. it guards itself against reentrance problems. self-aware queen π
hdlcdrv_transmitter actually prepares the bits to be transmitted. it should be called with interrupts on. it guards itself against reentrance problems. same energy π
hdlcdrv_arbitrate does the channel access algorithm (p-persistent CSMA). it should be called once every 10ms. note that the hardware driver must set the hdrv.par.bitrate field prior to starting operation so that hdlcdrv can calculate the transmitter keyup delay correctly. don't skip this step fr fr π
π₯ HARDWARE DRIVER ENTRY POINTS π₯
the hardware driver should provide the following information to the HDLC driver:
struct hdlcdrv_ops {
const char *drvname;
const char *drvinfo;
int (*open)(struct device *);
int (*close)(struct device *);
int (*ioctl)(struct device *, struct ifreq *, int);
};
drvname and drvinfo are just for informational purposes. cute, low-key decorative π
the following routines receive a pointer to the device structure, where they may find the io address, irq and dma channels:
openβ must be provided. it is called duringifconfig ifname upand should check for the hardware, grab it and initialize it. it usually installs an interrupt handler which then gets invoked by the hardware. glow up moment β¨closeβ must be provided. it is called duringifconfig ifname downand should undo all actions done byopen, i.e. release io regions and irqs. cleanup era π§Ήioctlβ may be provided to implement device specific ioctl's. optional icon π
π IOCTL CALLS π
the driver only responds to SIOCDEVPRIVATE. parameters are passed from and to the driver using the following struct:
struct hdlcdrv_ioctl {
int cmd;
union {
struct hdlcdrv_params mp;
struct hdlcdrv_channel_params cp;
struct hdlcdrv_channel_state cs;
unsigned int calibrate;
unsigned char bits;
} data;
};
so here's the tea: since the 16 private ioctl request numbers for network drivers were not enough, the driver implements its own sub request number with cmd. the following numbers are implemented:
HDLCDRVCTL_GETMODEMPARβ returns the IO parameters of the modem indata.mp. this includes the io address, irq, eventually dma, and ports to output a PTT signal. π‘HDLCDRVCTL_SETMODEMPARβ sets the modem parameters. only superuser can do this. parameters can only be changed if the interface is not running (i.e. down). no sneaky edits mid-flight πHDLCDRVCTL_GETCHANNELPARβ returns the channel access parameters. πHDLCDRVCTL_SETCHANNELPARβ sets the channel access parameters. only superuser can do this. they may also be changed using thekissparmscommand if using kernel AX.25, or theparamcommand of*NOS. πHDLCDRVCTL_GETSTATβ statistics and status information, such as if a carrier is detected on the channel and if the interface is currently transmitting. the vibe check command fr πΈHDLCDRVCTL_CALIBRATEβ instructs the driver to transmit a calibration pattern for the specified number of seconds. β±οΈHDLCDRVCTL_GETSAMPLESβ returns the bits delivered by the hardware driver withhdlcdrv_channelbit. the bits are returned 8 at a time with the least significant bit the first one. this command may not be available, depending on debugging settings. πHDLCDRVCTL_GETBITSβ returns the bits delivered by the hardware driver to the HDLC decoder. the bits are returned 8 at a time with the least significant bit the first one. this command may not be available, depending on debugging settings. β
π«Ά SEE ALSO π«Ά
baycom (9), soundmodem (9), sethdlc (8), linux/drivers/net/hdlcdrv.c, β go read those next bestie, they're all part of the same little ecosystem π
π AUTHOR π
hdlcdrv was written by Thomas Sailer, HB9JNX/AE4WA, (t.sailer@alumni.ethz.ch). legend behavior, honestly π
and that's the whole page!! you made it to the end bestie, so proud π¦β¨ this was Linux 2.1.x, dated 27 April 2008 β mwah, bye, go key up a transmitter responsibly π π
π¦ where this page comes from
- alpine 3.24: ax25-tools-doc 1.1.0-r0 Β· GPL-2.0-or-later
- debian bookworm: ax25-tools 0.0.10-rc5+git20190411+3595f87-6
- debian trixie: ax25-tools 0.0.10-rc5+git20230513+d3e6d4f-3 Β· GPL-2.0-only
- nixos 26.05: ax25-tools 0.0.10-rc5
- ubuntu jammy: ax25-tools 0.0.10-rc5+git20190411+3595f87-5
- ubuntu noble: ax25-tools 0.0.10-rc5+git20230513+d3e6d4f-1build2 Β· GPL-2.0-only
- ubuntu questing: ax25-tools 0.0.10-rc5+git20230513+d3e6d4f-3
- ubuntu resolute: ax25-tools 0.0.10-rc5+git20230513+d3e6d4f-3build1 Β· GPL-2.0-only
- ubuntu stonking: ax25-tools 0.0.10-rc5+git20230513+d3e6d4f-3build1 Β· GPL-2.0-only
- Copyright 1996 Thomas Sailer (t.sailer@alumni.ethz.ch)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms