iPXE
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
nic.h File Reference
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <byteswap.h>
#include <ipxe/pci.h>
#include <ipxe/isapnp.h>
#include <ipxe/isa.h>
#include <ipxe/eisa.h>
#include <ipxe/mca.h>
#include <ipxe/io.h>

Go to the source code of this file.

Data Structures

struct  nic
 
struct  nic_operations
 

Macros

#define NIC_H
 
#define PCI_DRIVER(_name, _ids, _class)
 
#define ISAPNP_DRIVER(_name, _ids)
 
#define EISA_DRIVER(_name, _ids)
 
#define MCA_DRIVER(_name, _ids)
 
#define ISA_DRIVER(_name, _probe_addrs, _probe_addr, _vendor_id, _prod_id)
 
#define DRIVER(_name_text, _unused2, _unused3, _name, _probe, _disable)
 

Typedefs

typedef enum duplex duplex_t
 

Enumerations

enum  irq_action_t { DISABLE = 0, ENABLE, FORCE }
 
enum  duplex { HALF_DUPLEX = 1, FULL_DUPLEX }
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static int eth_poll (int retrieve)
 
static void eth_transmit (const char *dest, unsigned int type, unsigned int size, const void *packet)
 
int dummy_connect (struct nic *nic)
 
void dummy_irq (struct nic *nic, irq_action_t irq_action)
 
int legacy_probe (void *hwdev, void(*set_drvdata)(void *hwdev, void *priv), struct device *dev, int(*probe)(struct nic *nic, void *hwdev), void(*disable)(struct nic *nic, void *hwdev))
 
void legacy_remove (void *hwdev, void *(*get_drvdata)(void *hwdev), void(*disable)(struct nic *nic, void *hwdev))
 
static void legacy_pci_set_drvdata (void *hwdev, void *priv)
 
static void * legacy_pci_get_drvdata (void *hwdev)
 
static void legacy_isapnp_set_drvdata (void *hwdev, void *priv)
 
static void * legacy_isapnp_get_drvdata (void *hwdev)
 
static void legacy_eisa_set_drvdata (void *hwdev, void *priv)
 
static void * legacy_eisa_get_drvdata (void *hwdev)
 
static void legacy_mca_set_drvdata (void *hwdev, void *priv)
 
static void * legacy_mca_get_drvdata (void *hwdev)
 
static void legacy_isa_set_drvdata (void *hwdev, void *priv)
 
static void * legacy_isa_get_drvdata (void *hwdev)
 

Variables

struct nic nic
 

Macro Definition Documentation

◆ NIC_H

#define NIC_H

Definition at line 21 of file nic.h.

◆ PCI_DRIVER

#define PCI_DRIVER (   _name,
  _ids,
  _class 
)
Value:
static inline int \
_name ## _pci_legacy_probe ( struct pci_device *pci ); \
static inline void \
_name ## _pci_legacy_remove ( struct pci_device *pci ); \
struct pci_driver _name __pci_driver = { \
.ids = _ids, \
.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
.probe = _name ## _pci_legacy_probe, \
.remove = _name ## _pci_legacy_remove, \
}; \
REQUIRE_OBJECT ( pci );
A PCI driver.
Definition: pci.h:247
#define __pci_driver
Declare a PCI driver.
Definition: pci.h:273
A PCI device.
Definition: pci.h:206

Definition at line 96 of file nic.h.

◆ ISAPNP_DRIVER

#define ISAPNP_DRIVER (   _name,
  _ids 
)
Value:
static inline int \
_name ## _isapnp_legacy_probe ( struct isapnp_device *isapnp, \
const struct isapnp_device_id *id ); \
static inline void \
_name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ); \
struct isapnp_driver _name __isapnp_driver = { \
.ids = _ids, \
.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
.probe = _name ## _isapnp_legacy_probe, \
.remove = _name ## _isapnp_legacy_remove, \
}; \
REQUIRE_OBJECT ( isapnp );
An ISAPnP driver.
Definition: isapnp.h:209
An ISAPnP device ID list entry.
Definition: isapnp.h:173
An ISAPnP device.
Definition: isapnp.h:183
#define __isapnp_driver
Declare an ISAPnP driver.
Definition: isapnp.h:235

Definition at line 116 of file nic.h.

◆ EISA_DRIVER

#define EISA_DRIVER (   _name,
  _ids 
)
Value:
static inline int \
_name ## _eisa_legacy_probe ( struct eisa_device *eisa, \
const struct eisa_device_id *id ); \
static inline void \
_name ## _eisa_legacy_remove ( struct eisa_device *eisa ); \
struct eisa_driver _name __eisa_driver = { \
.ids = _ids, \
.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
.probe = _name ## _eisa_legacy_probe, \
.remove = _name ## _eisa_legacy_remove, \
}; \
REQUIRE_OBJECT ( eisa );
#define __eisa_driver
Declare an EISA driver.
Definition: eisa.h:86
An EISA device.
Definition: eisa.h:38
An EISA device ID list entry.
Definition: eisa.h:28
An EISA driver.
Definition: eisa.h:60

Definition at line 137 of file nic.h.

◆ MCA_DRIVER

#define MCA_DRIVER (   _name,
  _ids 
)
Value:
static inline int \
_name ## _mca_legacy_probe ( struct mca_device *mca, \
const struct mca_device_id *id ); \
static inline void \
_name ## _mca_legacy_remove ( struct mca_device *mca ); \
struct mca_driver _name __mca_driver = { \
.ids = _ids, \
.id_count = sizeof ( _ids ) / sizeof ( _ids[0] ), \
.probe = _name ## _mca_legacy_probe, \
.remove = _name ## _mca_legacy_remove, \
}; \
REQUIRE_OBJECT ( mca );
An MCA driver.
Definition: mca.h:58
An MCA device.
Definition: mca.h:38
#define __mca_driver
Declare an MCA driver.
Definition: mca.h:84
An MCA device ID list entry.
Definition: mca.h:30

Definition at line 158 of file nic.h.

◆ ISA_DRIVER

#define ISA_DRIVER (   _name,
  _probe_addrs,
  _probe_addr,
  _vendor_id,
  _prod_id 
)
Value:
static inline int \
_name ## _isa_legacy_probe ( struct isa_device *isa ); \
static inline int \
_name ## _isa_legacy_probe_at_addr ( struct isa_device *isa ) { \
if ( ! _probe_addr ( isa->ioaddr ) ) \
return -ENODEV; \
return _name ## _isa_legacy_probe ( isa ); \
} \
static inline void \
_name ## _isa_legacy_remove ( struct isa_device *isa ); \
static const char _name ## _text[]; \
struct isa_driver _name __isa_driver = { \
.name = _name ## _text, \
.probe_addrs = _probe_addrs, \
.addr_count = ( sizeof ( _probe_addrs ) / \
sizeof ( _probe_addrs[0] ) ), \
.vendor_id = _vendor_id, \
.prod_id = _prod_id, \
.probe = _name ## _isa_legacy_probe_at_addr, \
.remove = _name ## _isa_legacy_remove, \
}; \
REQUIRE_OBJECT ( isa );
uint16_t ioaddr
I/O address.
Definition: isa.h:16
An ISA device.
Definition: isa.h:12
uint8_t vendor_id[3]
Definition: ib_mad.h:22
#define ENODEV
No such device.
Definition: errno.h:509
#define __isa_driver
Declare an ISA driver.
Definition: isa.h:65
An ISA driver.
Definition: isa.h:34

Definition at line 179 of file nic.h.

◆ DRIVER

#define DRIVER (   _name_text,
  _unused2,
  _unused3,
  _name,
  _probe,
  _disable 
)

Definition at line 211 of file nic.h.

Typedef Documentation

◆ duplex_t

typedef enum duplex duplex_t

Enumeration Type Documentation

◆ irq_action_t

Enumerator
DISABLE 
ENABLE 
FORCE 

Definition at line 34 of file nic.h.

34  {
35  DISABLE = 0,
36  ENABLE,
37  FORCE
38 } irq_action_t;
Definition: nic.h:35
irq_action_t
Definition: nic.h:34
Definition: nic.h:37
Definition: nic.h:36

◆ duplex

enum duplex
Enumerator
HALF_DUPLEX 
FULL_DUPLEX 

Definition at line 40 of file nic.h.

40  {
41  HALF_DUPLEX = 1,
43 } duplex_t;
enum duplex duplex_t

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ eth_poll()

static int eth_poll ( int  retrieve)
inlinestatic

Definition at line 72 of file nic.h.

72  {
73  return nic.nic_op->poll ( &nic, retrieve );
74 }
int(* poll)(struct nic *, int retrieve)
Definition: nic.h:64
Definition: nic.h:49
struct nic_operations * nic_op
Definition: nic.h:50

References nic::nic_op, and nic_operations::poll.

◆ eth_transmit()

static void eth_transmit ( const char *  dest,
unsigned int  type,
unsigned int  size,
const void *  packet 
)
inlinestatic

Definition at line 76 of file nic.h.

77  {
78  nic.nic_op->transmit ( &nic, dest, type, size, packet );
79 }
void(* transmit)(struct nic *, const char *, unsigned int, unsigned int, const char *)
Definition: nic.h:65
static void * dest
Definition: strings.h:176
Definition: nic.h:49
uint32_t type
Operating system type.
Definition: ena.h:12
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
struct nic_operations * nic_op
Definition: nic.h:50

References dest, nic::nic_op, nic::packet, size, nic_operations::transmit, and type.

◆ dummy_connect()

int dummy_connect ( struct nic nic)

◆ dummy_irq()

void dummy_irq ( struct nic nic,
irq_action_t  irq_action 
)

◆ legacy_probe()

int legacy_probe ( void *  hwdev,
void(*)(void *hwdev, void *priv set_drvdata,
struct device dev,
int(*)(struct nic *nic, void *hwdev)  probe,
void(*)(struct nic *nic, void *hwdev)  disable 
)

Definition at line 82 of file legacy.c.

86  {
87  struct net_device *netdev;
88  int rc;
89 
90  if ( legacy_registered )
91  return -EBUSY;
92 
93  netdev = alloc_etherdev ( 0 );
94  if ( ! netdev )
95  return -ENOMEM;
97  netdev->priv = &nic;
98  memset ( &nic, 0, sizeof ( nic ) );
99  set_drvdata ( hwdev, netdev );
100  netdev->dev = dev;
101 
103  nic.irqno = dev->desc.irq;
104 
105  if ( ! probe ( &nic, hwdev ) ) {
106  rc = -ENODEV;
107  goto err_probe;
108  }
109 
110  /* Overwrite the IRQ number. Some legacy devices set
111  * nic->irqno to 0 in the probe routine to indicate that they
112  * don't support interrupts; doing this allows the timer
113  * interrupt to be used instead.
114  */
115  dev->desc.irq = nic.irqno;
116 
117  if ( ( rc = register_netdev ( netdev ) ) != 0 )
118  goto err_register;
119 
120  /* Mark as link up; legacy devices don't handle link state */
122 
123  /* Do not remove this message */
124  printf ( "WARNING: Using legacy NIC wrapper on %s\n",
126 
127  legacy_registered = 1;
128  return 0;
129 
130  err_register:
131  disable ( &nic, hwdev );
132  err_probe:
134  netdev_put ( netdev );
135  return rc;
136 }
unsigned char irqno
Definition: nic.h:56
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static struct net_device_operations legacy_operations
Definition: legacy.c:74
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
#define ENOMEM
Not enough space.
Definition: errno.h:534
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
unsigned int irq
IRQ.
Definition: device.h:39
void * priv
Driver private data.
Definition: netdevice.h:431
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:774
static struct net_device * netdev
Definition: gdbudp.c:52
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
A network device.
Definition: netdevice.h:352
#define ENODEV
No such device.
Definition: errno.h:509
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
Definition: nic.h:49
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
unsigned char * node_addr
Definition: nic.h:52
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
struct device_description desc
Device description.
Definition: device.h:79
const char *(* ntoa)(const void *ll_addr)
Transcribe link-layer address.
Definition: netdevice.h:163
struct nic nic
Definition: legacy.c:22
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
static int legacy_registered
Definition: legacy.c:24
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:372
void * memset(void *dest, int character, size_t len) __nonnull

References alloc_etherdev(), device::desc, net_device::dev, EBUSY, ENODEV, ENOMEM, net_device::hw_addr, device_description::irq, nic::irqno, legacy_operations, legacy_registered, net_device::ll_protocol, memset(), netdev, netdev_init(), netdev_link_up(), netdev_nullify(), netdev_put(), nic, nic::node_addr, ll_protocol::ntoa, printf(), net_device::priv, rc, and register_netdev().

Referenced by t509_probe().

◆ legacy_remove()

void legacy_remove ( void *  hwdev,
void *(*)(void *hwdev)  get_drvdata,
void(*)(struct nic *nic, void *hwdev)  disable 
)

Definition at line 138 of file legacy.c.

140  {
141  struct net_device *netdev = get_drvdata ( hwdev );
142  struct nic *nic = netdev->priv;
143 
145  disable ( nic, hwdev );
147  netdev_put ( netdev );
148  legacy_registered = 0;
149 }
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
Definition: nic.h:49
static int legacy_registered
Definition: legacy.c:24

References legacy_registered, netdev, netdev_nullify(), netdev_put(), net_device::priv, and unregister_netdev().

Referenced by t509_remove().

◆ legacy_pci_set_drvdata()

static void legacy_pci_set_drvdata ( void *  hwdev,
void *  priv 
)
inlinestatic

Definition at line 109 of file nic.h.

109  {
110  pci_set_drvdata ( hwdev, priv );
111 }
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
static struct tlan_private * priv
Definition: tlan.c:224

References pci_set_drvdata(), and priv.

◆ legacy_pci_get_drvdata()

static void* legacy_pci_get_drvdata ( void *  hwdev)
inlinestatic

Definition at line 112 of file nic.h.

112  {
113  return pci_get_drvdata ( hwdev );
114 }
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:369

References pci_get_drvdata().

◆ legacy_isapnp_set_drvdata()

static void legacy_isapnp_set_drvdata ( void *  hwdev,
void *  priv 
)
inlinestatic

Definition at line 130 of file nic.h.

130  {
131  isapnp_set_drvdata ( hwdev, priv );
132 }
static void isapnp_set_drvdata(struct isapnp_device *isapnp, void *priv)
Set ISAPnP driver-private data.
Definition: isapnp.h:266
static struct tlan_private * priv
Definition: tlan.c:224

References isapnp_set_drvdata(), and priv.

◆ legacy_isapnp_get_drvdata()

static void* legacy_isapnp_get_drvdata ( void *  hwdev)
inlinestatic

Definition at line 133 of file nic.h.

133  {
134  return isapnp_get_drvdata ( hwdev );
135 }
static void * isapnp_get_drvdata(struct isapnp_device *isapnp)
Get ISAPnP driver-private data.
Definition: isapnp.h:277

References isapnp_get_drvdata().

◆ legacy_eisa_set_drvdata()

static void legacy_eisa_set_drvdata ( void *  hwdev,
void *  priv 
)
inlinestatic

Definition at line 151 of file nic.h.

151  {
152  eisa_set_drvdata ( hwdev, priv );
153 }
static void eisa_set_drvdata(struct eisa_device *eisa, void *priv)
Set EISA driver-private data.
Definition: eisa.h:114
static struct tlan_private * priv
Definition: tlan.c:224

References eisa_set_drvdata(), and priv.

◆ legacy_eisa_get_drvdata()

static void* legacy_eisa_get_drvdata ( void *  hwdev)
inlinestatic

Definition at line 154 of file nic.h.

154  {
155  return eisa_get_drvdata ( hwdev );
156 }
static void * eisa_get_drvdata(struct eisa_device *eisa)
Get EISA driver-private data.
Definition: eisa.h:124

References eisa_get_drvdata().

◆ legacy_mca_set_drvdata()

static void legacy_mca_set_drvdata ( void *  hwdev,
void *  priv 
)
inlinestatic

Definition at line 172 of file nic.h.

172  {
173  mca_set_drvdata ( hwdev, priv );
174 }
static void mca_set_drvdata(struct mca_device *mca, void *priv)
Set MCA driver-private data.
Definition: mca.h:92
static struct tlan_private * priv
Definition: tlan.c:224

References mca_set_drvdata(), and priv.

◆ legacy_mca_get_drvdata()

static void* legacy_mca_get_drvdata ( void *  hwdev)
inlinestatic

Definition at line 175 of file nic.h.

175  {
176  return mca_get_drvdata ( hwdev );
177 }
static void * mca_get_drvdata(struct mca_device *mca)
Get MCA driver-private data.
Definition: mca.h:102

References mca_get_drvdata().

◆ legacy_isa_set_drvdata()

static void legacy_isa_set_drvdata ( void *  hwdev,
void *  priv 
)
inlinestatic

Definition at line 203 of file nic.h.

203  {
204  isa_set_drvdata ( hwdev, priv );
205 }
static void isa_set_drvdata(struct isa_device *isa, void *priv)
Set ISA driver-private data.
Definition: isa.h:73
static struct tlan_private * priv
Definition: tlan.c:224

References isa_set_drvdata(), and priv.

◆ legacy_isa_get_drvdata()

static void* legacy_isa_get_drvdata ( void *  hwdev)
inlinestatic

Definition at line 206 of file nic.h.

206  {
207  return isa_get_drvdata ( hwdev );
208 }
static void * isa_get_drvdata(struct isa_device *isa)
Get ISA driver-private data.
Definition: isa.h:83

References isa_get_drvdata().

Variable Documentation

◆ nic

struct nic nic

Definition at line 22 of file legacy.c.

Referenced by amd8111e_probe(), bnx2_init_board(), ibft_install(), and legacy_probe().