iPXE
Functions | Variables
skeleton.c File Reference

Skeleton network driver. More...

#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include "skeleton.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int skeleton_reset (struct skeleton_nic *skel)
 Reset hardware.
static void skeleton_check_link (struct net_device *netdev)
 Check link state.
static int skeleton_open (struct net_device *netdev)
 Open network device.
static void skeleton_close (struct net_device *netdev)
 Close network device.
static int skeleton_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet.
static void skeleton_poll (struct net_device *netdev)
 Poll for completed and received packets.
static void skeleton_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts.
static int skeleton_probe (struct pci_device *pci)
 Probe PCI device.
static void skeleton_remove (struct pci_device *pci)
 Remove PCI device.

Variables

static struct net_device_operations skeleton_operations
 Skeleton network device operations.
static struct pci_device_id skeleton_nics []
 Skeleton PCI device IDs.
struct pci_driver skeleton_driver __pci_driver
 Skeleton PCI driver.

Detailed Description

Skeleton network driver.

Definition in file skeleton.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static int skeleton_reset ( struct skeleton_nic skel) [static]

Reset hardware.

Parameters:
skelSkeleton device
Return values:
rcReturn status code

Definition at line 58 of file skeleton.c.

References DBGC, and ENOTSUP.

Referenced by skeleton_probe(), and skeleton_remove().

                                                        {

        DBGC ( skel, "SKELETON %p does not yet support reset\n", skel );
        return -ENOTSUP;
}
static void skeleton_check_link ( struct net_device netdev) [static]

Check link state.

Parameters:
netdevNetwork device

Definition at line 76 of file skeleton.c.

References DBGC, ENOTSUP, netdev_link_err(), and net_device::priv.

Referenced by skeleton_probe().

                                                              {
        struct skeleton_nic *skel = netdev->priv;

        DBGC ( skel, "SKELETON %p does not yet support link state\n", skel );
        netdev_link_err ( netdev, -ENOTSUP );
}
static int skeleton_open ( struct net_device netdev) [static]

Open network device.

Parameters:
netdevNetwork device
Return values:
rcReturn status code

Definition at line 96 of file skeleton.c.

References DBGC, ENOTSUP, and net_device::priv.

                                                       {
        struct skeleton_nic *skel = netdev->priv;

        DBGC ( skel, "SKELETON %p does not yet support open\n", skel );
        return -ENOTSUP;
}
static void skeleton_close ( struct net_device netdev) [static]

Close network device.

Parameters:
netdevNetwork device

Definition at line 108 of file skeleton.c.

References DBGC, and net_device::priv.

                                                         {
        struct skeleton_nic *skel = netdev->priv;

        DBGC ( skel, "SKELETON %p does not yet support close\n", skel );
}
static int skeleton_transmit ( struct net_device netdev,
struct io_buffer iobuf 
) [static]

Transmit packet.

Parameters:
netdevNetwork device
iobufI/O buffer
Return values:
rcReturn status code

Definition at line 121 of file skeleton.c.

References DBGC, ENOTSUP, and net_device::priv.

                                                         {
        struct skeleton_nic *skel = netdev->priv;

        DBGC ( skel, "SKELETON %p does not yet support transmit\n", skel );
        ( void ) iobuf;
        return -ENOTSUP;
}
static void skeleton_poll ( struct net_device netdev) [static]

Poll for completed and received packets.

Parameters:
netdevNetwork device

Definition at line 135 of file skeleton.c.

References net_device::priv.

                                                        {
        struct skeleton_nic *skel = netdev->priv;

        /* Not yet implemented */
        ( void ) skel;
}
static void skeleton_irq ( struct net_device netdev,
int  enable 
) [static]

Enable or disable interrupts.

Parameters:
netdevNetwork device
enableInterrupts should be enabled

Definition at line 148 of file skeleton.c.

References DBGC, and net_device::priv.

                                                                   {
        struct skeleton_nic *skel = netdev->priv;

        DBGC ( skel, "SKELETON %p does not yet support interrupts\n", skel );
        ( void ) enable;
}
static int skeleton_probe ( struct pci_device pci) [static]

Probe PCI device.

Parameters:
pciPCI device
Return values:
rcReturn status code

Definition at line 177 of file skeleton.c.

References adjust_pci_device(), alloc_etherdev(), pci_device::dev, net_device::dev, ENODEV, ENOMEM, ioremap(), iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), pci_set_drvdata(), net_device::priv, rc, register_netdev(), skeleton_nic::regs, SKELETON_BAR_SIZE, skeleton_check_link(), skeleton_reset(), and unregister_netdev().

                                                     {
        struct net_device *netdev;
        struct skeleton_nic *skel;
        int rc;

        /* Allocate and initialise net device */
        netdev = alloc_etherdev ( sizeof ( *skel ) );
        if ( ! netdev ) {
                rc = -ENOMEM;
                goto err_alloc;
        }
        netdev_init ( netdev, &skeleton_operations );
        skel = netdev->priv;
        pci_set_drvdata ( pci, netdev );
        netdev->dev = &pci->dev;
        memset ( skel, 0, sizeof ( *skel ) );

        /* Fix up PCI device */
        adjust_pci_device ( pci );

        /* Map registers */
        skel->regs = ioremap ( pci->membase, SKELETON_BAR_SIZE );
        if ( ! skel->regs ) {
                rc = -ENODEV;
                goto err_ioremap;
        }

        /* Reset the NIC */
        if ( ( rc = skeleton_reset ( skel ) ) != 0 )
                goto err_reset;

        /* Register network device */
        if ( ( rc = register_netdev ( netdev ) ) != 0 )
                goto err_register_netdev;

        /* Set initial link state */
        skeleton_check_link ( netdev );

        return 0;

        unregister_netdev ( netdev );
 err_register_netdev:
        skeleton_reset ( skel );
 err_reset:
        iounmap ( skel->regs );
 err_ioremap:
        netdev_nullify ( netdev );
        netdev_put ( netdev );
 err_alloc:
        return rc;
}
static void skeleton_remove ( struct pci_device pci) [static]

Remove PCI device.

Parameters:
pciPCI device

Definition at line 234 of file skeleton.c.

References iounmap(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, skeleton_nic::regs, skeleton_reset(), and unregister_netdev().

                                                       {
        struct net_device *netdev = pci_get_drvdata ( pci );
        struct skeleton_nic *skel = netdev->priv;

        /* Unregister network device */
        unregister_netdev ( netdev );

        /* Reset card */
        skeleton_reset ( skel );

        /* Free network device */
        iounmap ( skel->regs );
        netdev_nullify ( netdev );
        netdev_put ( netdev );
}

Variable Documentation

Initial value:
 {
        .open           = skeleton_open,
        .close          = skeleton_close,
        .transmit       = skeleton_transmit,
        .poll           = skeleton_poll,
        .irq            = skeleton_irq,
}

Skeleton network device operations.

Definition at line 156 of file skeleton.c.

struct pci_device_id skeleton_nics[] [static]
Initial value:
 {
        PCI_ROM ( 0x5ce1, 0x5ce1, "skel",       "Skeleton", 0 ),
}

Skeleton PCI device IDs.

Definition at line 251 of file skeleton.c.

struct pci_driver skeleton_driver __pci_driver
Initial value:
 {
        .ids = skeleton_nics,
        .id_count = ( sizeof ( skeleton_nics ) / sizeof ( skeleton_nics[0] ) ),
        .probe = skeleton_probe,
        .remove = skeleton_remove,
}

Skeleton PCI driver.

Definition at line 256 of file skeleton.c.