3 #include <gpxe/if_ether.h>
4 #include <gpxe/netdevice.h>
5 #include <gpxe/ethernet.h>
6 #include <gpxe/pkbuff.h>
10 * Quick and dirty compatibility layer
12 * This should allow old-API PCI drivers to at least function until
13 * they are updated. It will not help non-PCI drivers.
15 * No drivers should rely on this code. It will be removed asap.
21 static int legacy_transmit ( struct net_device *netdev, struct pk_buff *pkb ) {
22 struct nic *nic = netdev->priv;
23 struct ethhdr *ethhdr = pkb->data;
26 pad_len = ( ETH_ZLEN - pkb_len ( pkb ) );
28 memset ( pkb_put ( pkb, pad_len ), 0, pad_len );
29 pkb_pull ( pkb, sizeof ( *ethhdr ) );
30 nic->nic_op->transmit ( nic, ( const char * ) ethhdr->h_dest,
31 ntohs ( ethhdr->h_protocol ),
32 pkb_len ( pkb ), pkb->data );
37 static void legacy_poll ( struct net_device *netdev ) {
38 struct nic *nic = netdev->priv;
41 pkb = alloc_pkb ( ETH_FRAME_LEN );
45 nic->packet = pkb->data;
46 if ( nic->nic_op->poll ( nic, 1 ) ) {
47 pkb_put ( pkb, nic->packetlen );
48 netdev_rx ( netdev, pkb );
54 int legacy_probe ( struct pci_device *pci,
55 const struct pci_device_id *id __unused,
56 int ( * probe ) ( struct nic *nic,
57 struct pci_device *pci ),
58 void ( * disable ) ( struct nic *nic ) ) {
59 struct net_device *netdev;
62 netdev = alloc_etherdev ( 0 );
66 memset ( &nic, 0, sizeof ( nic ) );
67 pci_set_drvdata ( pci, netdev );
69 netdev->transmit = legacy_transmit;
70 netdev->poll = legacy_poll;
71 nic.node_addr = netdev->ll_addr;
73 if ( ! probe ( &nic, pci ) ) {
74 free_netdev ( netdev );
78 if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
80 free_netdev ( netdev );
87 void legacy_remove ( struct pci_device *pci,
88 void ( * disable ) ( struct nic *nic ) ) {
89 struct net_device *netdev = pci_get_drvdata ( pci );
90 struct nic *nic = netdev->priv;
92 unregister_netdev ( netdev );
94 free_netdev ( netdev );
97 void pci_fill_nic ( struct nic *nic, struct pci_device *pci ) {
98 nic->ioaddr = pci->ioaddr;
99 nic->irqno = pci->irq;
102 int dummy_connect ( struct nic *nic __unused ) {
106 void dummy_irq ( struct nic *nic __unused, irq_action_t irq_action __unused ) {