iPXE
|
Remote Network Driver Interface Specification. More...
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/device.h>
#include <ipxe/rndis.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static struct io_buffer * | rndis_alloc_iob (size_t len) |
Allocate I/O buffer. More... | |
static int | rndis_wait (struct rndis_device *rndis, unsigned int wait_id) |
Wait for completion. More... | |
static int | rndis_tx_message (struct rndis_device *rndis, struct io_buffer *iobuf, unsigned int type) |
Transmit message. More... | |
void | rndis_tx_complete_err (struct rndis_device *rndis, struct io_buffer *iobuf, int rc) |
Complete message transmission. More... | |
static int | rndis_tx_data (struct rndis_device *rndis, struct io_buffer *iobuf) |
Transmit data packet. More... | |
int | rndis_tx_defer (struct rndis_device *rndis, struct io_buffer *iobuf) |
Defer transmitted packet. More... | |
static void | rndis_rx_data (struct rndis_device *rndis, struct io_buffer *iobuf) |
Receive data packet. More... | |
static int | rndis_tx_initialise (struct rndis_device *rndis, unsigned int id) |
Transmit initialisation message. More... | |
static void | rndis_rx_initialise (struct rndis_device *rndis, struct io_buffer *iobuf) |
Receive initialisation completion. More... | |
static int | rndis_initialise (struct rndis_device *rndis) |
Initialise RNDIS. More... | |
static int | rndis_tx_halt (struct rndis_device *rndis) |
Transmit halt message. More... | |
static int | rndis_halt (struct rndis_device *rndis) |
Halt RNDIS. More... | |
static int | rndis_tx_oid (struct rndis_device *rndis, unsigned int oid, const void *data, size_t len) |
Transmit OID message. More... | |
static void | rndis_rx_query_oid (struct rndis_device *rndis, struct io_buffer *iobuf) |
Receive query OID completion. More... | |
static void | rndis_rx_set_oid (struct rndis_device *rndis, struct io_buffer *iobuf) |
Receive set OID completion. More... | |
static int | rndis_oid (struct rndis_device *rndis, unsigned int oid, const void *data, size_t len) |
Query or set OID. More... | |
static int | rndis_describe (struct rndis_device *rndis) |
Describe RNDIS device. More... | |
static void | rndis_rx_status (struct rndis_device *rndis, struct io_buffer *iobuf) |
Receive indicate status message. More... | |
static void | rndis_rx_message (struct rndis_device *rndis, struct io_buffer *iobuf, unsigned int type) |
Receive RNDIS message. More... | |
void | rndis_rx (struct rndis_device *rndis, struct io_buffer *iobuf) |
Receive packet from underlying transport layer. More... | |
void | rndis_rx_err (struct rndis_device *rndis, struct io_buffer *iobuf, int rc) |
Discard packet from underlying transport layer. More... | |
static int | rndis_filter (struct rndis_device *rndis, unsigned int filter) |
Set receive filter. More... | |
static int | rndis_open (struct net_device *netdev) |
Open network device. More... | |
static void | rndis_close (struct net_device *netdev) |
Close network device. More... | |
static int | rndis_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | rndis_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
struct rndis_device * | alloc_rndis (size_t priv_len) |
Allocate RNDIS device. More... | |
int | register_rndis (struct rndis_device *rndis) |
Register RNDIS device. More... | |
void | unregister_rndis (struct rndis_device *rndis) |
Unregister RNDIS device. More... | |
void | free_rndis (struct rndis_device *rndis) |
Free RNDIS device. More... | |
Variables | |
static struct net_device_operations | rndis_operations |
Network device operations. More... | |
Remote Network Driver Interface Specification.
Definition in file rndis.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
Allocate I/O buffer.
len | Length |
iobuf | I/O buffer, or NULL |
Definition at line 48 of file rndis.c.
References alloc_iob(), header, iob_reserve, and len.
Referenced by rndis_tx_halt(), rndis_tx_initialise(), and rndis_tx_oid().
|
static |
Wait for completion.
rndis | RNDIS device |
wait_id | Request ID |
rc | Return status code |
Definition at line 67 of file rndis.c.
References DBGC, ETIMEDOUT, mdelay(), rndis_device::name, rndis_device::op, rndis_operations::poll, RNDIS_MAX_WAIT_MS, rndis_device::wait_id, and rndis_device::wait_rc.
Referenced by rndis_initialise(), and rndis_oid().
|
static |
Transmit message.
rndis | RNDIS device |
iobuf | I/O buffer |
type | Message type |
rc | Return status code |
Definition at line 100 of file rndis.c.
References cpu_to_le32, DBGC, header, iob_len(), iob_push, rndis_device::name, rndis_device::op, rc, strerror(), rndis_operations::transmit, and type.
Referenced by rndis_tx_data(), rndis_tx_halt(), rndis_tx_initialise(), and rndis_tx_oid().
void rndis_tx_complete_err | ( | struct rndis_device * | rndis, |
struct io_buffer * | iobuf, | ||
int | rc | ||
) |
Complete message transmission.
rndis | RNDIS device |
iobuf | I/O buffer |
rc | Packet status code |
Definition at line 127 of file rndis.c.
References cpu_to_le32, io_buffer::data, DBGC, DBGC_HDA, EINVAL, free_iob(), header, iob_len(), len, rndis_device::name, netdev, rndis_device::netdev, netdev_tx_complete_err(), netdev_tx_err(), NULL, rc, and RNDIS_PACKET_MSG.
Referenced by acm_out_complete(), netvsc_cancel_transmit(), and rndis_tx_complete().
|
static |
Transmit data packet.
rndis | RNDIS device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 158 of file rndis.c.
References cpu_to_le32, iob_len(), iob_push, len, memset(), msg(), rc, RNDIS_PACKET_MSG, and rndis_tx_message().
Referenced by rndis_transmit().
int rndis_tx_defer | ( | struct rndis_device * | rndis, |
struct io_buffer * | iobuf | ||
) |
Defer transmitted packet.
rndis | RNDIS device |
iobuf | I/O buffer |
rc | Return status code |
As with netdev_tx_defer(), the caller must ensure that space in the transmit descriptor ring is freed up before calling rndis_tx_complete().
Unlike netdev_tx_defer(), this call may fail.
Definition at line 190 of file rndis.c.
References assert(), cpu_to_le32, io_buffer::data, ENOTSUP, header, iob_len(), iob_pull, msg(), netdev, rndis_device::netdev, netdev_tx_defer(), and RNDIS_PACKET_MSG.
Referenced by netvsc_transmit().
|
static |
Receive data packet.
rndis | RNDIS device |
iobuf | I/O buffer |
Definition at line 221 of file rndis.c.
References io_buffer::data, data_len, DBGC, DBGC_HDA, EINVAL, iob_disown, iob_len(), iob_pull, iob_unput, le32_to_cpu, len, msg(), rndis_device::name, netdev, rndis_device::netdev, netdev_rx(), netdev_rx_err(), and rc.
Referenced by rndis_rx_message().
|
static |
Transmit initialisation message.
rndis | RNDIS device |
id | Request ID |
rc | Return status code |
Definition at line 273 of file rndis.c.
References cpu_to_le32, ENOMEM, free_iob(), id, iob_put, memset(), msg(), rc, rndis_alloc_iob(), RNDIS_INITIALISE_MSG, RNDIS_MTU, rndis_tx_message(), RNDIS_VERSION_MAJOR, and RNDIS_VERSION_MINOR.
Referenced by rndis_initialise().
|
static |
Receive initialisation completion.
rndis | RNDIS device |
iobuf | I/O buffer |
Definition at line 312 of file rndis.c.
References io_buffer::data, DBGC, DBGC_HDA, EINVAL, EIO, free_iob(), id, rndis_initialise_completion::id, iob_len(), le32_to_cpu, len, rndis_device::name, rc, rndis_initialise_completion::status, rndis_device::wait_id, and rndis_device::wait_rc.
Referenced by rndis_rx_message().
|
static |
Initialise RNDIS.
rndis | RNDIS device |
rc | Return status code |
Definition at line 360 of file rndis.c.
References rc, RNDIS_INIT_ID, rndis_tx_initialise(), and rndis_wait().
Referenced by rndis_describe(), and rndis_open().
|
static |
Transmit halt message.
rndis | RNDIS device |
rc | Return status code |
Definition at line 380 of file rndis.c.
References ENOMEM, free_iob(), iob_put, memset(), msg(), rc, rndis_alloc_iob(), RNDIS_HALT_MSG, and rndis_tx_message().
Referenced by rndis_halt().
|
static |
Halt RNDIS.
rndis | RNDIS device |
rc | Return status code |
Definition at line 414 of file rndis.c.
References rc, and rndis_tx_halt().
Referenced by rndis_close(), rndis_describe(), and rndis_open().
|
static |
Transmit OID message.
rndis | RNDIS device |
oid | Object ID |
data | New OID value (or NULL to query current value) |
len | Length of new OID value |
rc | Return status code |
Definition at line 433 of file rndis.c.
References cpu_to_le32, data, ENOMEM, free_iob(), iob_put, len, memcpy(), memset(), msg(), rndis_oid_message::oid, rc, rndis_alloc_iob(), RNDIS_QUERY_MSG, RNDIS_SET_MSG, rndis_tx_message(), and type.
Referenced by rndis_oid().
|
static |
Receive query OID completion.
rndis | RNDIS device |
iobuf | I/O buffer |
Definition at line 475 of file rndis.c.
References io_buffer::data, DBGC, DBGC_HDA, EINVAL, EIO, EPROTO, free_iob(), net_device::hw_addr, id, rndis_query_completion::id, info, info_len, iob_len(), le32_to_cpu, len, rndis_query_completion::len, net_device::ll_addr, memcpy(), rndis_device::name, netdev, rndis_device::netdev, netdev_link_down(), netdev_link_up(), rndis_query_completion::offset, rc, RNDIS_OID_802_3_CURRENT_ADDRESS, RNDIS_OID_802_3_PERMANENT_ADDRESS, RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, rndis_query_completion::status, rndis_device::wait_id, and rndis_device::wait_rc.
Referenced by rndis_rx_message().
|
static |
Receive set OID completion.
rndis | RNDIS device |
iobuf | I/O buffer |
Definition at line 586 of file rndis.c.
References io_buffer::data, DBGC, DBGC_HDA, EINVAL, EIO, free_iob(), id, rndis_set_completion::id, iob_len(), le32_to_cpu, len, rndis_device::name, rc, rndis_set_completion::status, rndis_device::wait_id, and rndis_device::wait_rc.
Referenced by rndis_rx_message().
|
static |
Query or set OID.
rndis | RNDIS device |
oid | Object ID |
data | New OID value (or NULL to query current value) |
len | Length of new OID value |
rc | Return status code |
Definition at line 638 of file rndis.c.
References data, len, rc, rndis_tx_oid(), and rndis_wait().
Referenced by rndis_describe(), rndis_filter(), and rndis_open().
|
static |
Describe RNDIS device.
rndis | RNDIS device |
rc | Return status code |
Definition at line 659 of file rndis.c.
References rndis_operations::close, DBGC, net_device::dev, device::name, rndis_device::name, netdev, rndis_device::netdev, NULL, rndis_device::op, rndis_operations::open, rc, rndis_halt(), rndis_initialise(), rndis_oid(), RNDIS_OID_802_3_CURRENT_ADDRESS, RNDIS_OID_802_3_PERMANENT_ADDRESS, RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, and strerror().
Referenced by register_rndis().
|
static |
Receive indicate status message.
rndis | RNDIS device |
iobuf | I/O buffer |
Definition at line 716 of file rndis.c.
References io_buffer::data, DBGC, DBGC_HDA, EINVAL, ENOTSUP, free_iob(), iob_len(), le32_to_cpu, len, msg(), rndis_device::name, netdev, rndis_device::netdev, netdev_link_down(), netdev_link_up(), netdev_rx_err(), rc, RNDIS_STATUS_MEDIA_CONNECT, RNDIS_STATUS_MEDIA_DISCONNECT, RNDIS_STATUS_WTF_WORLD, and status.
Referenced by rndis_rx_message().
|
static |
Receive RNDIS message.
rndis | RNDIS device |
iobuf | I/O buffer |
type | Message type |
Definition at line 780 of file rndis.c.
References io_buffer::data, DBGC, DBGC_HDA, EPROTO, iob_disown, iob_len(), rndis_device::name, netdev, rndis_device::netdev, netdev_rx_err(), rc, RNDIS_INDICATE_STATUS_MSG, RNDIS_INITIALISE_CMPLT, RNDIS_PACKET_MSG, RNDIS_QUERY_CMPLT, rndis_rx_data(), rndis_rx_initialise(), rndis_rx_query_oid(), rndis_rx_set_oid(), rndis_rx_status(), RNDIS_SET_CMPLT, and type.
Referenced by rndis_rx().
void rndis_rx | ( | struct rndis_device * | rndis, |
struct io_buffer * | iobuf | ||
) |
Receive packet from underlying transport layer.
rndis | RNDIS device |
iobuf | I/O buffer |
Definition at line 829 of file rndis.c.
References io_buffer::data, DBGC, DBGC_HDA, EINVAL, header, iob_disown, iob_len(), iob_pull, le32_to_cpu, rndis_device::name, netdev, rndis_device::netdev, netdev_rx_err(), rc, rndis_rx_message(), and type.
Referenced by acm_control_receive(), acm_in_complete(), and netvsc_recv_data().
void rndis_rx_err | ( | struct rndis_device * | rndis, |
struct io_buffer * | iobuf, | ||
int | rc | ||
) |
Discard packet from underlying transport layer.
rndis | RNDIS device |
iobuf | I/O buffer |
rc | Packet status code |
Definition at line 866 of file rndis.c.
References iob_disown, netdev, rndis_device::netdev, netdev_rx_err(), and rc.
Referenced by acm_in_complete(), acm_intr_complete(), and acm_poll().
|
static |
Set receive filter.
rndis | RNDIS device |
filter | Receive filter |
rc | Return status code |
Definition at line 881 of file rndis.c.
References cpu_to_le32, DBGC, filter, rndis_device::name, rc, rndis_oid(), RNDIS_OID_GEN_CURRENT_PACKET_FILTER, strerror(), and value.
Referenced by rndis_close(), and rndis_open().
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 902 of file rndis.c.
References rndis_operations::close, DBGC, rndis_device::name, netdev, NULL, rndis_device::op, rndis_operations::open, net_device::priv, rc, rndis_filter(), RNDIS_FILTER_ALL_MULTICAST, RNDIS_FILTER_BROADCAST, RNDIS_FILTER_MULTICAST, RNDIS_FILTER_PROMISCUOUS, RNDIS_FILTER_UNICAST, rndis_halt(), rndis_initialise(), rndis_oid(), RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, and strerror().
|
static |
Close network device.
netdev | Network device |
Definition at line 946 of file rndis.c.
References rndis_operations::close, netdev, rndis_device::op, net_device::priv, rndis_filter(), and rndis_halt().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 966 of file rndis.c.
References netdev, net_device::priv, and rndis_tx_data().
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 979 of file rndis.c.
References netdev, rndis_device::op, rndis_operations::poll, and net_device::priv.
struct rndis_device* alloc_rndis | ( | size_t | priv_len | ) |
Allocate RNDIS device.
priv_len | Length of private data |
rndis | RNDIS device, or NULL on allocation failure |
Definition at line 1000 of file rndis.c.
References alloc_etherdev(), netdev, rndis_device::netdev, netdev_init(), NULL, rndis_device::priv, and net_device::priv.
Referenced by acm_probe(), and netvsc_probe().
int register_rndis | ( | struct rndis_device * | rndis | ) |
Register RNDIS device.
rndis | RNDIS device |
rc | Return status code |
Note that this routine will open and use the RNDIS device in order to query the MAC address. The device must be immediately ready for use prior to registration.
Definition at line 1026 of file rndis.c.
References DBGC, rndis_device::name, netdev, rndis_device::netdev, rc, register_netdev(), rndis_describe(), strerror(), and unregister_netdev().
Referenced by acm_probe(), and netvsc_probe().
void unregister_rndis | ( | struct rndis_device * | rndis | ) |
Unregister RNDIS device.
rndis | RNDIS device |
Definition at line 1054 of file rndis.c.
References netdev, rndis_device::netdev, and unregister_netdev().
Referenced by acm_probe(), acm_remove(), netvsc_probe(), and netvsc_remove().
void free_rndis | ( | struct rndis_device * | rndis | ) |
Free RNDIS device.
rndis | RNDIS device |
Definition at line 1066 of file rndis.c.
References netdev, rndis_device::netdev, netdev_nullify(), and netdev_put().
Referenced by acm_probe(), acm_remove(), netvsc_probe(), and netvsc_remove().
|
static |
Network device operations.