2005-05-24 01:32:56 +02:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* PXE UNDI API
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2004 Michael Brown <mbrown@fensystems.co.uk>.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-07-20 20:55:45 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301, USA.
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
|
|
|
|
2009-05-01 16:41:06 +02:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER );
|
|
|
|
|
2007-06-30 16:56:00 +02:00
|
|
|
#include <stdint.h>
|
2007-07-02 21:05:58 +02:00
|
|
|
#include <stdio.h>
|
2007-06-30 16:56:00 +02:00
|
|
|
#include <string.h>
|
2007-07-02 18:43:32 +02:00
|
|
|
#include <byteswap.h>
|
2007-07-02 21:05:58 +02:00
|
|
|
#include <basemem_packet.h>
|
2010-04-19 21:16:01 +02:00
|
|
|
#include <ipxe/netdevice.h>
|
|
|
|
#include <ipxe/iobuf.h>
|
|
|
|
#include <ipxe/device.h>
|
|
|
|
#include <ipxe/pci.h>
|
|
|
|
#include <ipxe/if_ether.h>
|
|
|
|
#include <ipxe/ip.h>
|
|
|
|
#include <ipxe/arp.h>
|
|
|
|
#include <ipxe/rarp.h>
|
2005-05-24 01:32:56 +02:00
|
|
|
#include "pxe.h"
|
|
|
|
|
2007-07-03 00:49:00 +02:00
|
|
|
/**
|
|
|
|
* Count of outstanding transmitted packets
|
|
|
|
*
|
|
|
|
* This is incremented each time PXENV_UNDI_TRANSMIT is called, and
|
|
|
|
* decremented each time that PXENV_UNDI_ISR is called with the TX
|
|
|
|
* queue empty, stopping when the count reaches zero. This allows us
|
|
|
|
* to provide a pessimistic approximation of TX completion events to
|
|
|
|
* the PXE NBP simply by monitoring the netdev's TX queue.
|
|
|
|
*/
|
|
|
|
static int undi_tx_count = 0;
|
|
|
|
|
2007-07-03 21:21:16 +02:00
|
|
|
struct net_device *pxe_netdev = NULL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set network device as current PXE network device
|
|
|
|
*
|
|
|
|
* @v netdev Network device, or NULL
|
|
|
|
*/
|
|
|
|
void pxe_set_netdev ( struct net_device *netdev ) {
|
2011-12-08 03:35:23 +01:00
|
|
|
|
2010-11-20 17:47:49 +01:00
|
|
|
if ( pxe_netdev ) {
|
|
|
|
netdev_rx_unfreeze ( pxe_netdev );
|
2007-07-03 21:21:16 +02:00
|
|
|
netdev_put ( pxe_netdev );
|
2010-11-20 17:47:49 +01:00
|
|
|
}
|
2011-12-08 03:35:23 +01:00
|
|
|
|
2007-07-03 21:21:16 +02:00
|
|
|
pxe_netdev = NULL;
|
2011-12-08 03:35:23 +01:00
|
|
|
|
2007-07-03 21:21:16 +02:00
|
|
|
if ( netdev )
|
|
|
|
pxe_netdev = netdev_get ( netdev );
|
|
|
|
}
|
|
|
|
|
2007-07-03 01:02:06 +02:00
|
|
|
/**
|
|
|
|
* Open PXE network device
|
|
|
|
*
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int pxe_netdev_open ( void ) {
|
2007-07-07 17:43:39 +02:00
|
|
|
int rc;
|
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
assert ( pxe_netdev != NULL );
|
|
|
|
|
2007-07-07 17:43:39 +02:00
|
|
|
if ( ( rc = netdev_open ( pxe_netdev ) ) != 0 )
|
|
|
|
return rc;
|
|
|
|
|
2010-11-20 17:47:49 +01:00
|
|
|
netdev_rx_freeze ( pxe_netdev );
|
2007-07-07 17:43:39 +02:00
|
|
|
netdev_irq ( pxe_netdev, 1 );
|
2011-12-08 03:35:23 +01:00
|
|
|
|
2007-07-07 17:43:39 +02:00
|
|
|
return 0;
|
2007-07-03 01:02:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close PXE network device
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void pxe_netdev_close ( void ) {
|
2011-12-08 03:35:23 +01:00
|
|
|
|
|
|
|
assert ( pxe_netdev != NULL );
|
2010-11-20 17:47:49 +01:00
|
|
|
netdev_rx_unfreeze ( pxe_netdev );
|
2007-07-07 17:43:39 +02:00
|
|
|
netdev_irq ( pxe_netdev, 0 );
|
2007-07-03 01:02:06 +02:00
|
|
|
netdev_close ( pxe_netdev );
|
|
|
|
undi_tx_count = 0;
|
|
|
|
}
|
|
|
|
|
2009-06-27 16:45:27 +02:00
|
|
|
/**
|
|
|
|
* Dump multicast address list
|
|
|
|
*
|
|
|
|
* @v mcast PXE multicast address list
|
|
|
|
*/
|
|
|
|
static void pxe_dump_mcast_list ( struct s_PXENV_UNDI_MCAST_ADDRESS *mcast ) {
|
|
|
|
struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for ( i = 0 ; i < mcast->MCastAddrCount ; i++ ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " %s",
|
|
|
|
ll_protocol->ntoa ( mcast->McastAddr[i] ) );
|
2009-06-27 16:45:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
/* PXENV_UNDI_STARTUP
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP *undi_startup ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_STARTUP\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_STARTUP called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_startup->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_startup->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_CLEANUP
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP *undi_cleanup ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_CLEANUP\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_CLEANUP called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_cleanup->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close network device */
|
2007-07-03 01:02:06 +02:00
|
|
|
pxe_netdev_close();
|
2007-07-03 00:49:00 +02:00
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_cleanup->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_INITIALIZE
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_initialize ( struct s_PXENV_UNDI_INITIALIZE *undi_initialize ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_INITIALIZE protocolini %08x\n",
|
|
|
|
undi_initialize->ProtocolIni );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_INITIALIZE called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_initialize->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_initialize->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_RESET_ADAPTER
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET *undi_reset_adapter ) {
|
2007-07-03 00:49:00 +02:00
|
|
|
int rc;
|
|
|
|
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_RESET_ADAPTER" );
|
2009-06-27 16:45:27 +02:00
|
|
|
pxe_dump_mcast_list ( &undi_reset_adapter->R_Mcast_Buf );
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_RESET_ADAPTER called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_reset_adapter->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close and reopen network device */
|
2007-07-03 01:02:06 +02:00
|
|
|
pxe_netdev_close();
|
|
|
|
if ( ( rc = pxe_netdev_open() ) != 0 ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_RESET_ADAPTER could not "
|
|
|
|
"reopen %s: %s\n", pxe_netdev->name, strerror ( rc ) );
|
2007-07-03 00:49:00 +02:00
|
|
|
undi_reset_adapter->Status = PXENV_STATUS ( rc );
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_reset_adapter->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_SHUTDOWN
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN *undi_shutdown ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SHUTDOWN\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SHUTDOWN called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_shutdown->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close network device */
|
2007-07-03 01:02:06 +02:00
|
|
|
pxe_netdev_close();
|
2007-07-02 04:12:35 +02:00
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_shutdown->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_OPEN
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open ) {
|
2007-07-03 00:49:00 +02:00
|
|
|
int rc;
|
|
|
|
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_OPEN flag %04x filter %04x",
|
|
|
|
undi_open->OpenFlag, undi_open->PktFilter );
|
2009-06-27 16:45:27 +02:00
|
|
|
pxe_dump_mcast_list ( &undi_open->R_Mcast_Buf );
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_OPEN called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_open->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open network device */
|
2007-07-03 01:02:06 +02:00
|
|
|
if ( ( rc = pxe_netdev_open() ) != 0 ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_OPEN could not open %s: %s\n",
|
|
|
|
pxe_netdev->name, strerror ( rc ) );
|
2007-07-03 00:49:00 +02:00
|
|
|
undi_open->Status = PXENV_STATUS ( rc );
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
2005-05-24 01:32:56 +02:00
|
|
|
|
|
|
|
undi_open->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_CLOSE
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t pxenv_undi_close ( struct s_PXENV_UNDI_CLOSE *undi_close ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_CLOSE\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_CLOSE called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_close->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close network device */
|
2007-07-03 01:02:06 +02:00
|
|
|
pxe_netdev_close();
|
2007-07-03 00:49:00 +02:00
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_close->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_TRANSMIT
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT *undi_transmit ) {
|
2007-07-02 21:05:58 +02:00
|
|
|
struct s_PXENV_UNDI_TBD tbd;
|
|
|
|
struct DataBlk *datablk;
|
|
|
|
struct io_buffer *iobuf;
|
|
|
|
struct net_protocol *net_protocol;
|
2011-12-08 03:35:23 +01:00
|
|
|
struct ll_protocol *ll_protocol;
|
2007-07-02 21:05:58 +02:00
|
|
|
char destaddr[MAX_LL_ADDR_LEN];
|
|
|
|
const void *ll_dest;
|
|
|
|
size_t len;
|
|
|
|
unsigned int i;
|
|
|
|
int rc;
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_TRANSMIT called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC2 ( &pxe_netdev, "PXENV_UNDI_TRANSMIT" );
|
|
|
|
|
2010-11-20 17:47:49 +01:00
|
|
|
/* Forcibly enable interrupts and freeze receive queue
|
|
|
|
* processing at this point, to work around callers that never
|
|
|
|
* call PXENV_UNDI_OPEN before attempting to use the UNDI API.
|
2009-06-23 22:54:50 +02:00
|
|
|
*/
|
2010-11-20 17:47:49 +01:00
|
|
|
netdev_rx_freeze ( pxe_netdev );
|
2009-06-23 22:54:50 +02:00
|
|
|
netdev_irq ( pxe_netdev, 1 );
|
|
|
|
|
2007-07-02 21:05:58 +02:00
|
|
|
/* Identify network-layer protocol */
|
|
|
|
switch ( undi_transmit->Protocol ) {
|
|
|
|
case P_IP: net_protocol = &ipv4_protocol; break;
|
|
|
|
case P_ARP: net_protocol = &arp_protocol; break;
|
|
|
|
case P_RARP: net_protocol = &rarp_protocol; break;
|
2007-07-03 05:05:30 +02:00
|
|
|
case P_UNKNOWN:
|
|
|
|
net_protocol = NULL;
|
|
|
|
break;
|
2007-07-02 21:05:58 +02:00
|
|
|
default:
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " %02x invalid protocol\n",
|
|
|
|
undi_transmit->Protocol );
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_PARAMETER;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " %s",
|
|
|
|
( net_protocol ? net_protocol->name : "RAW" ) );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2007-07-02 21:05:58 +02:00
|
|
|
/* Calculate total packet length */
|
|
|
|
copy_from_real ( &tbd, undi_transmit->TBD.segment,
|
|
|
|
undi_transmit->TBD.offset, sizeof ( tbd ) );
|
|
|
|
len = tbd.ImmedLength;
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " %04x:%04x+%x", tbd.Xmit.segment, tbd.Xmit.offset,
|
|
|
|
tbd.ImmedLength );
|
2007-07-02 21:05:58 +02:00
|
|
|
for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
|
|
|
|
datablk = &tbd.DataBlock[i];
|
|
|
|
len += datablk->TDDataLen;
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " %04x:%04x+%x",
|
|
|
|
datablk->TDDataPtr.segment, datablk->TDDataPtr.offset,
|
|
|
|
datablk->TDDataLen );
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
2007-07-02 21:05:58 +02:00
|
|
|
/* Allocate and fill I/O buffer */
|
2010-11-19 16:37:08 +01:00
|
|
|
iobuf = alloc_iob ( MAX_LL_HEADER_LEN + len );
|
2007-07-02 21:05:58 +02:00
|
|
|
if ( ! iobuf ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " could not allocate iobuf\n" );
|
2007-07-02 21:05:58 +02:00
|
|
|
undi_transmit->Status = PXENV_STATUS_OUT_OF_RESOURCES;
|
2005-05-24 01:32:56 +02:00
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
2010-11-19 16:37:08 +01:00
|
|
|
iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
|
2007-07-02 21:05:58 +02:00
|
|
|
copy_from_real ( iob_put ( iobuf, tbd.ImmedLength ), tbd.Xmit.segment,
|
|
|
|
tbd.Xmit.offset, tbd.ImmedLength );
|
|
|
|
for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
|
|
|
|
datablk = &tbd.DataBlock[i];
|
|
|
|
copy_from_real ( iob_put ( iobuf, datablk->TDDataLen ),
|
|
|
|
datablk->TDDataPtr.segment,
|
|
|
|
datablk->TDDataPtr.offset,
|
|
|
|
datablk->TDDataLen );
|
|
|
|
}
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2008-08-20 04:21:37 +02:00
|
|
|
/* Add link-layer header, if required to do so */
|
|
|
|
if ( net_protocol != NULL ) {
|
|
|
|
|
2007-07-02 21:05:58 +02:00
|
|
|
/* Calculate destination address */
|
2011-12-08 03:35:23 +01:00
|
|
|
ll_protocol = pxe_netdev->ll_protocol;
|
2007-07-02 21:05:58 +02:00
|
|
|
if ( undi_transmit->XmitFlag == XMT_DESTADDR ) {
|
|
|
|
copy_from_real ( destaddr,
|
|
|
|
undi_transmit->DestAddr.segment,
|
|
|
|
undi_transmit->DestAddr.offset,
|
2008-10-15 05:17:48 +02:00
|
|
|
ll_protocol->ll_addr_len );
|
2007-07-02 21:05:58 +02:00
|
|
|
ll_dest = destaddr;
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " DEST %s",
|
|
|
|
ll_protocol->ntoa ( ll_dest ) );
|
2007-07-02 21:05:58 +02:00
|
|
|
} else {
|
2009-07-17 23:48:31 +02:00
|
|
|
ll_dest = pxe_netdev->ll_broadcast;
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " BCAST" );
|
2007-07-02 21:05:58 +02:00
|
|
|
}
|
2008-08-20 04:21:37 +02:00
|
|
|
|
|
|
|
/* Add link-layer header */
|
2009-06-15 20:37:43 +02:00
|
|
|
if ( ( rc = ll_protocol->push ( pxe_netdev, iobuf, ll_dest,
|
2008-10-15 05:17:48 +02:00
|
|
|
pxe_netdev->ll_addr,
|
|
|
|
net_protocol->net_proto ))!=0){
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, " could not add link-layer "
|
|
|
|
"header: %s\n", strerror ( rc ) );
|
2008-08-20 04:21:37 +02:00
|
|
|
free_iob ( iobuf );
|
|
|
|
undi_transmit->Status = PXENV_STATUS ( rc );
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-27 17:36:21 +02:00
|
|
|
/* Flag transmission as in-progress. Do this before starting
|
|
|
|
* to transmit the packet, because the ISR may trigger before
|
|
|
|
* we return from netdev_tx().
|
|
|
|
*/
|
|
|
|
undi_tx_count++;
|
|
|
|
|
2008-08-20 04:21:37 +02:00
|
|
|
/* Transmit packet */
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, "\n" );
|
2008-08-20 04:21:37 +02:00
|
|
|
if ( ( rc = netdev_tx ( pxe_netdev, iobuf ) ) != 0 ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC2 ( &pxe_netdev, "PXENV_UNDI_TRANSMIT could not transmit: "
|
|
|
|
"%s\n", strerror ( rc ) );
|
2009-06-27 17:36:21 +02:00
|
|
|
undi_tx_count--;
|
2008-08-20 04:21:37 +02:00
|
|
|
undi_transmit->Status = PXENV_STATUS ( rc );
|
|
|
|
return PXENV_EXIT_FAILURE;
|
2007-07-02 21:05:58 +02:00
|
|
|
}
|
|
|
|
|
2008-08-20 04:21:37 +02:00
|
|
|
undi_transmit->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_SET_MCAST_ADDRESS
|
|
|
|
*
|
2009-06-27 16:45:27 +02:00
|
|
|
* Status: working (for NICs that support receive-all-multicast)
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
2005-05-24 01:32:56 +02:00
|
|
|
pxenv_undi_set_mcast_address ( struct s_PXENV_UNDI_SET_MCAST_ADDRESS
|
|
|
|
*undi_set_mcast_address ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SET_MCAST_ADDRESS" );
|
2009-06-27 16:45:27 +02:00
|
|
|
pxe_dump_mcast_list ( &undi_set_mcast_address->R_Mcast_Buf );
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "\n" );
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SET_MCAST_ADDRESS called with "
|
|
|
|
"no network device\n" );
|
|
|
|
undi_set_mcast_address->Status =
|
|
|
|
PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-06-27 16:45:27 +02:00
|
|
|
undi_set_mcast_address->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_SET_STATION_ADDRESS
|
|
|
|
*
|
2007-07-02 18:43:32 +02:00
|
|
|
* Status: working
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
2005-05-24 01:32:56 +02:00
|
|
|
pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
|
|
|
|
*undi_set_station_address ) {
|
2011-12-08 03:35:23 +01:00
|
|
|
struct ll_protocol *ll_protocol;
|
|
|
|
|
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SET_STATION_ADDRESS called "
|
|
|
|
"with no network device\n" );
|
|
|
|
undi_set_station_address->Status =
|
|
|
|
PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
2007-07-02 18:43:32 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
ll_protocol = pxe_netdev->ll_protocol;
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SET_STATION_ADDRESS %s",
|
|
|
|
ll_protocol->ntoa ( undi_set_station_address->StationAddress ) );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2007-07-02 18:43:32 +02:00
|
|
|
/* If adapter is open, the change will have no effect; return
|
|
|
|
* an error
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2010-03-23 01:46:23 +01:00
|
|
|
if ( netdev_is_open ( pxe_netdev ) ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " failed: netdev is open\n" );
|
2007-07-02 18:43:32 +02:00
|
|
|
undi_set_station_address->Status =
|
|
|
|
PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2007-07-02 18:43:32 +02:00
|
|
|
/* Update MAC address */
|
|
|
|
memcpy ( pxe_netdev->ll_addr,
|
|
|
|
&undi_set_station_address->StationAddress,
|
2009-06-27 15:43:10 +02:00
|
|
|
ll_protocol->ll_addr_len );
|
2007-07-02 18:43:32 +02:00
|
|
|
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "\n" );
|
2007-07-03 01:57:53 +02:00
|
|
|
undi_set_station_address->Status = PXENV_STATUS_SUCCESS;
|
2007-07-02 18:43:32 +02:00
|
|
|
return PXENV_EXIT_SUCCESS;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_SET_PACKET_FILTER
|
|
|
|
*
|
|
|
|
* Status: won't implement (would require driver API changes for no
|
|
|
|
* real benefit)
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
2005-05-24 01:32:56 +02:00
|
|
|
pxenv_undi_set_packet_filter ( struct s_PXENV_UNDI_SET_PACKET_FILTER
|
|
|
|
*undi_set_packet_filter ) {
|
2009-06-23 22:54:50 +02:00
|
|
|
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SET_PACKET_FILTER %02x\n",
|
|
|
|
undi_set_packet_filter->filter );
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_SET_PACKET_FILTER called with "
|
|
|
|
"no network device\n" );
|
|
|
|
undi_set_packet_filter->Status =
|
|
|
|
PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-06-23 22:54:50 +02:00
|
|
|
/* Pretend that we succeeded, otherwise the 3Com DOS UNDI
|
|
|
|
* driver refuses to load. (We ignore the filter value in the
|
|
|
|
* PXENV_UNDI_OPEN call anyway.)
|
|
|
|
*/
|
|
|
|
undi_set_packet_filter->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_GET_INFORMATION
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_get_information ( struct s_PXENV_UNDI_GET_INFORMATION
|
|
|
|
*undi_get_information ) {
|
2011-12-08 03:35:23 +01:00
|
|
|
struct device *dev;
|
|
|
|
struct ll_protocol *ll_protocol;
|
2007-06-30 16:56:00 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_INFORMATION called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_get_information->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_INFORMATION" );
|
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Fill in information */
|
|
|
|
dev = pxe_netdev->dev;
|
|
|
|
ll_protocol = pxe_netdev->ll_protocol;
|
2007-07-02 18:43:32 +02:00
|
|
|
undi_get_information->BaseIo = dev->desc.ioaddr;
|
2011-03-10 19:25:05 +01:00
|
|
|
undi_get_information->IntNumber =
|
|
|
|
( netdev_irq_supported ( pxe_netdev ) ? dev->desc.irq : 0 );
|
2005-05-24 01:32:56 +02:00
|
|
|
/* Cheat: assume all cards can cope with this */
|
|
|
|
undi_get_information->MaxTranUnit = ETH_MAX_MTU;
|
2007-06-30 16:56:00 +02:00
|
|
|
undi_get_information->HwType = ntohs ( ll_protocol->ll_proto );
|
2011-12-08 03:35:23 +01:00
|
|
|
undi_get_information->HwAddrLen = ll_protocol->ll_addr_len;
|
|
|
|
assert ( ll_protocol->ll_addr_len <=
|
2009-08-12 00:40:27 +02:00
|
|
|
sizeof ( undi_get_information->CurrentNodeAddress ) );
|
2007-06-30 16:56:00 +02:00
|
|
|
memcpy ( &undi_get_information->CurrentNodeAddress,
|
|
|
|
pxe_netdev->ll_addr,
|
|
|
|
sizeof ( undi_get_information->CurrentNodeAddress ) );
|
2009-08-12 00:40:27 +02:00
|
|
|
ll_protocol->init_addr ( pxe_netdev->hw_addr,
|
|
|
|
&undi_get_information->PermNodeAddress );
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_get_information->ROMAddress = 0;
|
|
|
|
/* nic.rom_info->rom_segment; */
|
|
|
|
/* We only provide the ability to receive or transmit a single
|
|
|
|
* packet at a time. This is a bootloader, not an OS.
|
|
|
|
*/
|
|
|
|
undi_get_information->RxBufCt = 1;
|
|
|
|
undi_get_information->TxBufCt = 1;
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " io %04x irq %d mtu %d %s %s\n",
|
|
|
|
undi_get_information->BaseIo, undi_get_information->IntNumber,
|
|
|
|
undi_get_information->MaxTranUnit, ll_protocol->name,
|
|
|
|
ll_protocol->ntoa ( &undi_get_information->CurrentNodeAddress ));
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_get_information->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_GET_STATISTICS
|
|
|
|
*
|
2007-07-03 01:15:53 +02:00
|
|
|
* Status: working
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
|
|
|
|
*undi_get_statistics ) {
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_STATISTICS called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_get_statistics->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_STATISTICS" );
|
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Report statistics */
|
2008-11-08 03:18:30 +01:00
|
|
|
undi_get_statistics->XmtGoodFrames = pxe_netdev->tx_stats.good;
|
|
|
|
undi_get_statistics->RcvGoodFrames = pxe_netdev->rx_stats.good;
|
|
|
|
undi_get_statistics->RcvCRCErrors = pxe_netdev->rx_stats.bad;
|
|
|
|
undi_get_statistics->RcvResourceErrors = pxe_netdev->rx_stats.bad;
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " txok %d rxok %d rxcrc %d rxrsrc %d\n",
|
|
|
|
undi_get_statistics->XmtGoodFrames,
|
|
|
|
undi_get_statistics->RcvGoodFrames,
|
|
|
|
undi_get_statistics->RcvCRCErrors,
|
|
|
|
undi_get_statistics->RcvResourceErrors );
|
2011-12-08 03:35:23 +01:00
|
|
|
|
2007-07-03 01:15:53 +02:00
|
|
|
undi_get_statistics->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_CLEAR_STATISTICS
|
|
|
|
*
|
2007-07-03 01:15:53 +02:00
|
|
|
* Status: working
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
|
|
|
|
*undi_clear_statistics ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_CLEAR_STATISTICS\n" );
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_CLEAR_STATISTICS called with "
|
|
|
|
"no network device\n" );
|
|
|
|
undi_clear_statistics->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear statistics */
|
2008-11-08 03:18:30 +01:00
|
|
|
memset ( &pxe_netdev->tx_stats, 0, sizeof ( pxe_netdev->tx_stats ) );
|
|
|
|
memset ( &pxe_netdev->rx_stats, 0, sizeof ( pxe_netdev->rx_stats ) );
|
2007-07-03 01:15:53 +02:00
|
|
|
|
|
|
|
undi_clear_statistics->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_INITIATE_DIAGS
|
|
|
|
*
|
|
|
|
* Status: won't implement (would require driver API changes for no
|
|
|
|
* real benefit)
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_initiate_diags ( struct s_PXENV_UNDI_INITIATE_DIAGS
|
|
|
|
*undi_initiate_diags ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_INITIATE_DIAGS failed: unsupported\n" );
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_INITIATE_DIAGS called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_initiate_diags->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_initiate_diags->Status = PXENV_STATUS_UNSUPPORTED;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_FORCE_INTERRUPT
|
|
|
|
*
|
2007-07-03 16:36:29 +02:00
|
|
|
* Status: won't implement (would require driver API changes for no
|
|
|
|
* perceptible benefit)
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_force_interrupt ( struct s_PXENV_UNDI_FORCE_INTERRUPT
|
|
|
|
*undi_force_interrupt ) {
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev,
|
|
|
|
"PXENV_UNDI_FORCE_INTERRUPT failed: unsupported\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_FORCE_INTERRUPT called with no "
|
|
|
|
"network device\n" );
|
|
|
|
undi_force_interrupt->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2007-07-03 16:36:29 +02:00
|
|
|
undi_force_interrupt->Status = PXENV_STATUS_UNSUPPORTED;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_GET_MCAST_ADDRESS
|
|
|
|
*
|
2009-06-27 16:45:27 +02:00
|
|
|
* Status: working
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
2005-05-24 01:32:56 +02:00
|
|
|
pxenv_undi_get_mcast_address ( struct s_PXENV_UNDI_GET_MCAST_ADDRESS
|
|
|
|
*undi_get_mcast_address ) {
|
2011-12-08 03:35:23 +01:00
|
|
|
struct ll_protocol *ll_protocol;
|
2009-06-27 15:43:10 +02:00
|
|
|
struct in_addr ip = { .s_addr = undi_get_mcast_address->InetAddr };
|
2009-06-27 16:45:27 +02:00
|
|
|
int rc;
|
2009-06-27 15:43:10 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_MCAST_ADDRESS called with "
|
|
|
|
"no network device\n" );
|
|
|
|
undi_get_mcast_address->Status =
|
|
|
|
PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_MCAST_ADDRESS %s",
|
|
|
|
inet_ntoa ( ip ) );
|
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Hash address using the network device's link-layer protocol */
|
|
|
|
ll_protocol = pxe_netdev->ll_protocol;
|
2009-06-27 16:45:27 +02:00
|
|
|
if ( ( rc = ll_protocol->mc_hash ( AF_INET, &ip,
|
|
|
|
undi_get_mcast_address->MediaAddr ))!=0){
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " failed: %s\n", strerror ( rc ) );
|
2009-06-27 16:45:27 +02:00
|
|
|
undi_get_mcast_address->Status = PXENV_STATUS ( rc );
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, "=>%s\n",
|
|
|
|
ll_protocol->ntoa ( undi_get_mcast_address->MediaAddr ) );
|
2009-06-27 16:45:27 +02:00
|
|
|
|
|
|
|
undi_get_mcast_address->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_GET_NIC_TYPE
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t pxenv_undi_get_nic_type ( struct s_PXENV_UNDI_GET_NIC_TYPE
|
|
|
|
*undi_get_nic_type ) {
|
2011-12-08 03:35:23 +01:00
|
|
|
struct device *dev;
|
2007-06-30 16:56:00 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_NIC_TYPE called with "
|
|
|
|
"no network device\n" );
|
|
|
|
undi_get_nic_type->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_NIC_TYPE" );
|
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Fill in information */
|
2007-06-30 16:56:00 +02:00
|
|
|
memset ( &undi_get_nic_type->info, 0,
|
|
|
|
sizeof ( undi_get_nic_type->info ) );
|
2011-12-08 03:35:23 +01:00
|
|
|
dev = pxe_netdev->dev;
|
2007-06-30 16:56:00 +02:00
|
|
|
switch ( dev->desc.bus_type ) {
|
|
|
|
case BUS_TYPE_PCI: {
|
|
|
|
struct pci_nic_info *info = &undi_get_nic_type->info.pci;
|
2005-05-24 01:32:56 +02:00
|
|
|
|
|
|
|
undi_get_nic_type->NicType = PCI_NIC;
|
2007-07-02 18:43:32 +02:00
|
|
|
info->Vendor_ID = dev->desc.vendor;
|
|
|
|
info->Dev_ID = dev->desc.device;
|
|
|
|
info->Base_Class = PCI_BASE_CLASS ( dev->desc.class );
|
|
|
|
info->Sub_Class = PCI_SUB_CLASS ( dev->desc.class );
|
|
|
|
info->Prog_Intf = PCI_PROG_INTF ( dev->desc.class );
|
|
|
|
info->BusDevFunc = dev->desc.location;
|
2010-12-04 22:32:00 +01:00
|
|
|
/* Earlier versions of the PXE specification do not
|
|
|
|
* have the SubVendor_ID and SubDevice_ID fields. It
|
|
|
|
* is possible that some NBPs will not provide space
|
|
|
|
* for them, and so we must not fill them in.
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " PCI %02x:%02x.%x %04x:%04x "
|
|
|
|
"('%04x:%04x') %02x%02x%02x rev %02x\n",
|
|
|
|
PCI_BUS ( info->BusDevFunc ),
|
|
|
|
PCI_SLOT ( info->BusDevFunc ),
|
|
|
|
PCI_FUNC ( info->BusDevFunc ), info->Vendor_ID,
|
|
|
|
info->Dev_ID, info->SubVendor_ID, info->SubDevice_ID,
|
|
|
|
info->Base_Class, info->Sub_Class, info->Prog_Intf,
|
|
|
|
info->Rev );
|
2007-06-30 16:56:00 +02:00
|
|
|
break; }
|
|
|
|
case BUS_TYPE_ISAPNP: {
|
|
|
|
struct pnp_nic_info *info = &undi_get_nic_type->info.pnp;
|
2005-05-24 01:32:56 +02:00
|
|
|
|
|
|
|
undi_get_nic_type->NicType = PnP_NIC;
|
2007-07-02 18:43:32 +02:00
|
|
|
info->EISA_Dev_ID = ( ( dev->desc.vendor << 16 ) |
|
|
|
|
dev->desc.device );
|
|
|
|
info->CardSelNum = dev->desc.location;
|
2007-06-30 16:56:00 +02:00
|
|
|
/* Cheat: remaining fields are probably unnecessary,
|
|
|
|
* and would require adding extra code to isapnp.c.
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " ISAPnP CSN %04x %08x %02x%02x%02x\n",
|
|
|
|
info->CardSelNum, info->EISA_Dev_ID,
|
|
|
|
info->Base_Class, info->Sub_Class, info->Prog_Intf );
|
2007-06-30 16:56:00 +02:00
|
|
|
break; }
|
|
|
|
default:
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " failed: unknown bus type\n" );
|
2007-06-30 16:56:00 +02:00
|
|
|
undi_get_nic_type->Status = PXENV_STATUS_FAILURE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
2007-06-30 16:56:00 +02:00
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_get_nic_type->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_GET_IFACE_INFO
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t
|
|
|
|
pxenv_undi_get_iface_info ( struct s_PXENV_UNDI_GET_IFACE_INFO
|
|
|
|
*undi_get_iface_info ) {
|
2005-05-24 01:32:56 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_IFACE_INFO called with "
|
|
|
|
"no network device\n" );
|
|
|
|
undi_get_iface_info->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC ( &pxe_netdev, "PXENV_UNDI_GET_IFACE_INFO" );
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
/* Just hand back some info, doesn't really matter what it is.
|
|
|
|
* Most PXE stacks seem to take this approach.
|
|
|
|
*/
|
2007-07-02 21:05:58 +02:00
|
|
|
snprintf ( ( char * ) undi_get_iface_info->IfaceType,
|
2009-06-23 23:53:29 +02:00
|
|
|
sizeof ( undi_get_iface_info->IfaceType ), "DIX+802.3" );
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_get_iface_info->LinkSpeed = 10000000; /* 10 Mbps */
|
2009-06-23 23:42:55 +02:00
|
|
|
undi_get_iface_info->ServiceFlags =
|
|
|
|
( SUPPORTED_BROADCAST | SUPPORTED_MULTICAST |
|
|
|
|
SUPPORTED_SET_STATION_ADDRESS | SUPPORTED_RESET |
|
2011-01-25 15:18:15 +01:00
|
|
|
SUPPORTED_OPEN_CLOSE );
|
|
|
|
if ( netdev_irq_supported ( pxe_netdev ) )
|
|
|
|
undi_get_iface_info->ServiceFlags |= SUPPORTED_IRQ;
|
2005-05-24 01:32:56 +02:00
|
|
|
memset ( undi_get_iface_info->Reserved, 0,
|
|
|
|
sizeof(undi_get_iface_info->Reserved) );
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-11-14 13:48:15 +01:00
|
|
|
DBGC ( &pxe_netdev, " %s %dbps flags %08x\n",
|
|
|
|
undi_get_iface_info->IfaceType, undi_get_iface_info->LinkSpeed,
|
|
|
|
undi_get_iface_info->ServiceFlags );
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_get_iface_info->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PXENV_UNDI_GET_STATE
|
|
|
|
*
|
2011-12-11 02:35:49 +01:00
|
|
|
* Status: impossible due to opcode collision
|
2005-05-24 01:32:56 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* PXENV_UNDI_ISR
|
|
|
|
*
|
|
|
|
* Status: working
|
|
|
|
*/
|
2011-12-11 02:35:49 +01:00
|
|
|
static PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
|
2007-07-02 21:05:58 +02:00
|
|
|
struct io_buffer *iobuf;
|
|
|
|
size_t len;
|
2008-08-20 04:21:37 +02:00
|
|
|
struct ll_protocol *ll_protocol;
|
2008-10-15 05:17:48 +02:00
|
|
|
const void *ll_dest;
|
2008-08-20 04:21:37 +02:00
|
|
|
const void *ll_source;
|
|
|
|
uint16_t net_proto;
|
2011-07-15 19:48:46 +02:00
|
|
|
unsigned int flags;
|
2008-08-20 04:21:37 +02:00
|
|
|
size_t ll_hlen;
|
|
|
|
struct net_protocol *net_protocol;
|
|
|
|
unsigned int prottype;
|
|
|
|
int rc;
|
2007-07-02 21:05:58 +02:00
|
|
|
|
2011-11-14 13:48:15 +01:00
|
|
|
/* Use a different debug colour, since UNDI ISR messages are
|
|
|
|
* likely to be interspersed amongst other UNDI messages.
|
2009-06-27 15:43:10 +02:00
|
|
|
*/
|
2006-08-09 02:22:28 +02:00
|
|
|
|
2011-12-08 03:35:23 +01:00
|
|
|
/* Sanity check */
|
|
|
|
if ( ! pxe_netdev ) {
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC ( &pxenv_undi_isr, "PXENV_UNDI_ISR called with "
|
2011-12-08 03:35:23 +01:00
|
|
|
"no network device\n" );
|
|
|
|
undi_isr->Status = PXENV_STATUS_UNDI_INVALID_STATE;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-12-08 03:55:53 +01:00
|
|
|
DBGC2 ( &pxenv_undi_isr, "PXENV_UNDI_ISR" );
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
/* Just in case some idiot actually looks at these fields when
|
|
|
|
* we weren't meant to fill them in...
|
|
|
|
*/
|
|
|
|
undi_isr->BufferLength = 0;
|
|
|
|
undi_isr->FrameLength = 0;
|
|
|
|
undi_isr->FrameHeaderLength = 0;
|
|
|
|
undi_isr->ProtType = 0;
|
|
|
|
undi_isr->PktType = 0;
|
|
|
|
|
|
|
|
switch ( undi_isr->FuncFlag ) {
|
|
|
|
case PXENV_UNDI_ISR_IN_START :
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " START" );
|
2007-07-02 21:05:58 +02:00
|
|
|
|
|
|
|
/* Call poll(). This should acknowledge the device
|
|
|
|
* interrupt and queue up any received packet.
|
|
|
|
*/
|
2010-11-20 17:47:49 +01:00
|
|
|
net_poll();
|
2007-07-07 17:43:39 +02:00
|
|
|
|
[pxe] Avoid potential interrupt storms when using shared interrupts
Current gPXE code always returns "OURS" in response to
PXENV_UNDI_ISR:START. This is harmless for non-shared interrupt
lines, and avoids the complexity of trying to determine whether or not
we really did cause the interrupt. (This is a non-trivial
determination; some drivers don't have interrupt support and hook the
system timer interrupt instead, for example.)
A problem occurs when we have a shared interrupt line, the other
device asserts an interrupt, and the controlling ISR does not chain to
the other device's ISR when we return "OURS". Under these
circumstances, the other device's ISR never executes, and so the
interrupt remains asserted, causing an interrupt storm.
Work around this by returning "OURS" if and only if our net device's
interrupt is currently recorded as being enabled. Since we always
disable interrupts as a result of a call to PXENV_UNDI_ISR:START, this
guarantees that we will eventually (on the second call) return "NOT
OURS", allowing the other ISR to be called. Under normal operation,
including a non-shared interrupt situation, this change will make no
difference since PXENV_UNDI_ISR:START would be called only when
interrupts were enabled anyway.
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2010-03-23 01:58:52 +01:00
|
|
|
/* A 100% accurate determination of "OURS" vs "NOT
|
|
|
|
* OURS" is difficult to achieve without invasive and
|
|
|
|
* unpleasant changes to the driver model. We settle
|
|
|
|
* for always returning "OURS" if interrupts are
|
|
|
|
* currently enabled.
|
|
|
|
*
|
|
|
|
* Returning "NOT OURS" when interrupts are disabled
|
|
|
|
* allows us to avoid a potential interrupt storm when
|
|
|
|
* we are on a shared interrupt line; if we were to
|
|
|
|
* always return "OURS" then the other device's ISR
|
|
|
|
* may never be called.
|
|
|
|
*/
|
|
|
|
if ( netdev_irq_enabled ( pxe_netdev ) ) {
|
|
|
|
DBGC2 ( &pxenv_undi_isr, " OURS" );
|
|
|
|
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_OURS;
|
|
|
|
} else {
|
|
|
|
DBGC2 ( &pxenv_undi_isr, " NOT OURS" );
|
|
|
|
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_NOT_OURS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable interrupts */
|
2007-07-07 17:43:39 +02:00
|
|
|
netdev_irq ( pxe_netdev, 0 );
|
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
break;
|
|
|
|
case PXENV_UNDI_ISR_IN_PROCESS :
|
2007-07-02 21:05:58 +02:00
|
|
|
case PXENV_UNDI_ISR_IN_GET_NEXT :
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " %s",
|
|
|
|
( ( undi_isr->FuncFlag == PXENV_UNDI_ISR_IN_PROCESS ) ?
|
|
|
|
"PROCESS" : "GET_NEXT" ) );
|
2008-08-20 03:02:51 +02:00
|
|
|
|
|
|
|
/* Some dumb NBPs (e.g. emBoot's winBoot/i) never call
|
|
|
|
* PXENV_UNDI_ISR with FuncFlag=PXENV_UNDI_ISR_START;
|
|
|
|
* they just sit in a tight polling loop merrily
|
|
|
|
* violating the PXE spec with repeated calls to
|
|
|
|
* PXENV_UNDI_ISR_IN_PROCESS. Force extra polls to
|
|
|
|
* cope with these out-of-spec clients.
|
|
|
|
*/
|
2010-11-20 17:47:49 +01:00
|
|
|
net_poll();
|
2007-07-03 00:49:00 +02:00
|
|
|
|
|
|
|
/* If we have not yet marked a TX as complete, and the
|
|
|
|
* netdev TX queue is empty, report the TX completion.
|
|
|
|
*/
|
|
|
|
if ( undi_tx_count && list_empty ( &pxe_netdev->tx_queue ) ) {
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " TXC" );
|
2007-07-03 00:49:00 +02:00
|
|
|
undi_tx_count--;
|
|
|
|
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_TRANSMIT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-07-02 21:05:58 +02:00
|
|
|
/* Remove first packet from netdev RX queue */
|
|
|
|
iobuf = netdev_rx_dequeue ( pxe_netdev );
|
|
|
|
if ( ! iobuf ) {
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " DONE" );
|
2007-07-02 21:05:58 +02:00
|
|
|
/* No more packets remaining */
|
|
|
|
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_DONE;
|
2007-07-07 17:43:39 +02:00
|
|
|
/* Re-enable interrupts */
|
|
|
|
netdev_irq ( pxe_netdev, 1 );
|
2005-05-24 01:32:56 +02:00
|
|
|
break;
|
|
|
|
}
|
2007-07-02 21:05:58 +02:00
|
|
|
|
|
|
|
/* Copy packet to base memory buffer */
|
|
|
|
len = iob_len ( iobuf );
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " RX" );
|
2007-07-02 21:05:58 +02:00
|
|
|
if ( len > sizeof ( basemem_packet ) ) {
|
|
|
|
/* Should never happen */
|
2009-08-02 23:40:58 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " overlength (%zx)", len );
|
2007-07-03 01:57:53 +02:00
|
|
|
len = sizeof ( basemem_packet );
|
2005-05-24 01:32:56 +02:00
|
|
|
}
|
2007-07-02 21:05:58 +02:00
|
|
|
memcpy ( basemem_packet, iobuf->data, len );
|
|
|
|
|
2008-08-20 04:21:37 +02:00
|
|
|
/* Strip link-layer header */
|
|
|
|
ll_protocol = pxe_netdev->ll_protocol;
|
2009-06-15 20:37:43 +02:00
|
|
|
if ( ( rc = ll_protocol->pull ( pxe_netdev, iobuf, &ll_dest,
|
2011-07-15 19:48:46 +02:00
|
|
|
&ll_source, &net_proto,
|
|
|
|
&flags ) ) != 0 ) {
|
2008-08-20 04:21:37 +02:00
|
|
|
/* Assume unknown net_proto and no ll_source */
|
|
|
|
net_proto = 0;
|
|
|
|
ll_source = NULL;
|
|
|
|
}
|
|
|
|
ll_hlen = ( len - iob_len ( iobuf ) );
|
|
|
|
|
|
|
|
/* Determine network-layer protocol */
|
|
|
|
switch ( net_proto ) {
|
|
|
|
case htons ( ETH_P_IP ):
|
|
|
|
net_protocol = &ipv4_protocol;
|
|
|
|
prottype = P_IP;
|
|
|
|
break;
|
|
|
|
case htons ( ETH_P_ARP ):
|
|
|
|
net_protocol = &arp_protocol;
|
|
|
|
prottype = P_ARP;
|
|
|
|
break;
|
|
|
|
case htons ( ETH_P_RARP ):
|
|
|
|
net_protocol = &rarp_protocol;
|
|
|
|
prottype = P_RARP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
net_protocol = NULL;
|
|
|
|
prottype = P_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-07-03 01:57:53 +02:00
|
|
|
/* Fill in UNDI_ISR structure */
|
2007-07-02 21:05:58 +02:00
|
|
|
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_RECEIVE;
|
|
|
|
undi_isr->BufferLength = len;
|
|
|
|
undi_isr->FrameLength = len;
|
2008-08-20 04:21:37 +02:00
|
|
|
undi_isr->FrameHeaderLength = ll_hlen;
|
2007-07-02 21:05:58 +02:00
|
|
|
undi_isr->Frame.segment = rm_ds;
|
2008-07-01 03:52:13 +02:00
|
|
|
undi_isr->Frame.offset = __from_data16 ( basemem_packet );
|
2008-08-20 04:21:37 +02:00
|
|
|
undi_isr->ProtType = prottype;
|
2011-07-15 19:48:46 +02:00
|
|
|
if ( flags & LL_BROADCAST ) {
|
2010-12-06 19:33:57 +01:00
|
|
|
undi_isr->PktType = P_BROADCAST;
|
2011-07-15 19:48:46 +02:00
|
|
|
} else if ( flags & LL_MULTICAST ) {
|
2010-12-06 19:33:57 +01:00
|
|
|
undi_isr->PktType = P_MULTICAST;
|
2011-07-15 19:48:46 +02:00
|
|
|
} else {
|
|
|
|
undi_isr->PktType = P_DIRECTED;
|
2010-12-06 19:33:57 +01:00
|
|
|
}
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " %04x:%04x+%x(%x) %s hlen %d",
|
|
|
|
undi_isr->Frame.segment, undi_isr->Frame.offset,
|
|
|
|
undi_isr->BufferLength, undi_isr->FrameLength,
|
|
|
|
( net_protocol ? net_protocol->name : "RAW" ),
|
|
|
|
undi_isr->FrameHeaderLength );
|
2007-07-03 01:57:53 +02:00
|
|
|
|
|
|
|
/* Free packet */
|
|
|
|
free_iob ( iobuf );
|
2005-05-24 01:32:56 +02:00
|
|
|
break;
|
|
|
|
default :
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, " INVALID(%04x)\n",
|
|
|
|
undi_isr->FuncFlag );
|
2007-07-02 21:05:58 +02:00
|
|
|
|
2005-05-24 01:32:56 +02:00
|
|
|
/* Should never happen */
|
|
|
|
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_DONE;
|
|
|
|
undi_isr->Status = PXENV_STATUS_UNDI_INVALID_PARAMETER;
|
|
|
|
return PXENV_EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-06-27 15:43:10 +02:00
|
|
|
DBGC2 ( &pxenv_undi_isr, "\n" );
|
2005-05-24 01:32:56 +02:00
|
|
|
undi_isr->Status = PXENV_STATUS_SUCCESS;
|
|
|
|
return PXENV_EXIT_SUCCESS;
|
|
|
|
}
|
2011-12-11 02:35:49 +01:00
|
|
|
|
|
|
|
/** PXE UNDI API */
|
|
|
|
struct pxe_api_call pxe_undi_api[] __pxe_api_call = {
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_STARTUP, pxenv_undi_startup,
|
|
|
|
struct s_PXENV_UNDI_STARTUP ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_CLEANUP, pxenv_undi_cleanup,
|
|
|
|
struct s_PXENV_UNDI_CLEANUP ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_INITIALIZE, pxenv_undi_initialize,
|
|
|
|
struct s_PXENV_UNDI_INITIALIZE ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_RESET_ADAPTER, pxenv_undi_reset_adapter,
|
|
|
|
struct s_PXENV_UNDI_RESET ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_SHUTDOWN, pxenv_undi_shutdown,
|
|
|
|
struct s_PXENV_UNDI_SHUTDOWN ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_OPEN, pxenv_undi_open,
|
|
|
|
struct s_PXENV_UNDI_OPEN ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_CLOSE, pxenv_undi_close,
|
|
|
|
struct s_PXENV_UNDI_CLOSE ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_TRANSMIT, pxenv_undi_transmit,
|
|
|
|
struct s_PXENV_UNDI_TRANSMIT ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_SET_MCAST_ADDRESS,
|
|
|
|
pxenv_undi_set_mcast_address,
|
|
|
|
struct s_PXENV_UNDI_SET_MCAST_ADDRESS ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_SET_STATION_ADDRESS,
|
|
|
|
pxenv_undi_set_station_address,
|
|
|
|
struct s_PXENV_UNDI_SET_STATION_ADDRESS ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_SET_PACKET_FILTER,
|
|
|
|
pxenv_undi_set_packet_filter,
|
|
|
|
struct s_PXENV_UNDI_SET_PACKET_FILTER ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_GET_INFORMATION, pxenv_undi_get_information,
|
|
|
|
struct s_PXENV_UNDI_GET_INFORMATION ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_GET_STATISTICS, pxenv_undi_get_statistics,
|
|
|
|
struct s_PXENV_UNDI_GET_STATISTICS ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_CLEAR_STATISTICS, pxenv_undi_clear_statistics,
|
|
|
|
struct s_PXENV_UNDI_CLEAR_STATISTICS ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_INITIATE_DIAGS, pxenv_undi_initiate_diags,
|
|
|
|
struct s_PXENV_UNDI_INITIATE_DIAGS ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_FORCE_INTERRUPT, pxenv_undi_force_interrupt,
|
|
|
|
struct s_PXENV_UNDI_FORCE_INTERRUPT ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_GET_MCAST_ADDRESS,
|
|
|
|
pxenv_undi_get_mcast_address,
|
|
|
|
struct s_PXENV_UNDI_GET_MCAST_ADDRESS ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_GET_NIC_TYPE, pxenv_undi_get_nic_type,
|
|
|
|
struct s_PXENV_UNDI_GET_NIC_TYPE ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_GET_IFACE_INFO, pxenv_undi_get_iface_info,
|
|
|
|
struct s_PXENV_UNDI_GET_IFACE_INFO ),
|
|
|
|
PXE_API_CALL ( PXENV_UNDI_ISR, pxenv_undi_isr,
|
|
|
|
struct s_PXENV_UNDI_ISR ),
|
|
|
|
};
|