iPXE
Data Structures | Defines | Enumerations | Functions
rndis.h File Reference

Remote Network Driver Interface Specification. More...

#include <stdint.h>
#include <ipxe/netdevice.h>
#include <ipxe/iobuf.h>

Go to the source code of this file.

Data Structures

struct  rndis_header
 RNDIS message header. More...
struct  rndis_initialise_message
 RNDIS initialise message. More...
struct  rndis_initialise_completion
 RNDIS initialise completion. More...
struct  rndis_halt_message
 RNDIS halt message. More...
struct  rndis_oid_message
 RNDIS query or set OID message. More...
struct  rndis_query_completion
 RNDIS query OID completion. More...
struct  rndis_set_completion
 RNDIS set OID completion. More...
struct  rndis_reset_message
 RNDIS reset message. More...
struct  rndis_reset_completion
 RNDIS reset completion. More...
struct  rndis_diagnostic_info
 RNDIS diagnostic information. More...
struct  rndis_indicate_status_message
 RNDIS indicate status message. More...
struct  rndis_keepalive_message
 RNDIS keepalive message. More...
struct  rndis_keepalive_completion
 RNDIS keepalive completion. More...
struct  rndis_packet_field
 RNDIS packet field. More...
struct  rndis_packet_message
 RNDIS packet message. More...
struct  rndis_packet_record
 RNDIS packet record. More...
struct  rndis_operations
 RNDIS device operations. More...
struct  rndis_device
 An RNDIS device. More...

Defines

#define RNDIS_MAX_WAIT_MS   1000
 Maximum time to wait for a transaction to complete.
#define RNDIS_INITIALISE_MSG   0x00000002UL
 RNDIS initialise message.
#define RNDIS_INIT_ID   0xe110e110UL
 Request ID used for initialisation.
#define RNDIS_VERSION_MAJOR   1
 RNDIS major version.
#define RNDIS_VERSION_MINOR   0
 RNDIS minor version.
#define RNDIS_MTU   2048
 RNDIS maximum transfer size.
#define RNDIS_INITIALISE_CMPLT   0x80000002UL
 RNDIS initialise completion.
#define RNDIS_HALT_MSG   0x00000003UL
 RNDIS halt message.
#define RNDIS_QUERY_MSG   0x00000004UL
 RNDIS query OID message.
#define RNDIS_SET_MSG   0x00000005UL
 RNDIS set OID message.
#define RNDIS_QUERY_CMPLT   0x80000004UL
 RNDIS query OID completion.
#define RNDIS_SET_CMPLT   0x80000005UL
 RNDIS set OID completion.
#define RNDIS_RESET_MSG   0x00000006UL
 RNDIS reset message.
#define RNDIS_RESET_CMPLT   0x80000006UL
 RNDIS reset completion.
#define RNDIS_INDICATE_STATUS_MSG   0x00000007UL
 RNDIS indicate status message.
#define RNDIS_KEEPALIVE_MSG   0x00000008UL
 RNDIS keepalive message.
#define RNDIS_KEEPALIVE_CMPLT   0x80000008UL
 RNDIS keepalive completion.
#define RNDIS_PACKET_MSG   0x00000001UL
 RNDIS packet message.
#define RNDIS_OID_GEN_CURRENT_PACKET_FILTER   0x0001010eUL
 OID for packet filter.
#define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS   0x00010114UL
 OID for media status.
#define RNDIS_OID_802_3_PERMANENT_ADDRESS   0x01010101UL
 OID for permanent MAC address.
#define RNDIS_OID_802_3_CURRENT_ADDRESS   0x01010102UL
 OID for current MAC address.

Enumerations

enum  rndis_status { RNDIS_STATUS_MEDIA_CONNECT = 0x4001000bUL, RNDIS_STATUS_MEDIA_DISCONNECT = 0x4001000cUL, RNDIS_STATUS_WTF_WORLD = 0x40020006UL }
 RNDIS status codes. More...
enum  rndis_packet_filter {
  RNDIS_FILTER_UNICAST = 0x00000001UL, RNDIS_FILTER_MULTICAST = 0x00000002UL, RNDIS_FILTER_ALL_MULTICAST = 0x00000004UL, RNDIS_FILTER_BROADCAST = 0x00000008UL,
  RNDIS_FILTER_PROMISCUOUS = 0x00000020UL
}
 Packet filter bits. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static void rndis_init (struct rndis_device *rndis, struct rndis_operations *op)
 Initialise an RNDIS device.
void rndis_tx_complete_err (struct rndis_device *rndis, struct io_buffer *iobuf, int rc)
 Complete message transmission.
int rndis_tx_defer (struct rndis_device *rndis, struct io_buffer *iobuf)
 Defer transmitted packet.
void rndis_rx (struct rndis_device *rndis, struct io_buffer *iobuf)
 Receive packet from underlying transport layer.
void rndis_rx_err (struct rndis_device *rndis, struct io_buffer *iobuf, int rc)
 Discard packet from underlying transport layer.
struct rndis_devicealloc_rndis (size_t priv_len)
 Allocate RNDIS device.
int register_rndis (struct rndis_device *rndis)
 Register RNDIS device.
void unregister_rndis (struct rndis_device *rndis)
 Unregister RNDIS device.
void free_rndis (struct rndis_device *rndis)
 Free RNDIS device.
static void rndis_tx_complete (struct rndis_device *rndis, struct io_buffer *iobuf)
 Complete message transmission.

Detailed Description

Remote Network Driver Interface Specification.

Definition in file rndis.h.


Define Documentation

#define RNDIS_MAX_WAIT_MS   1000

Maximum time to wait for a transaction to complete.

This is a policy decision.

Definition at line 20 of file rndis.h.

Referenced by rndis_wait().

#define RNDIS_INITIALISE_MSG   0x00000002UL

RNDIS initialise message.

Definition at line 31 of file rndis.h.

Referenced by rndis_tx_initialise().

#define RNDIS_INIT_ID   0xe110e110UL

Request ID used for initialisation.

This is a policy decision.

Definition at line 49 of file rndis.h.

Referenced by rndis_initialise().

#define RNDIS_VERSION_MAJOR   1

RNDIS major version.

Definition at line 52 of file rndis.h.

Referenced by rndis_tx_initialise().

#define RNDIS_VERSION_MINOR   0

RNDIS minor version.

Definition at line 55 of file rndis.h.

Referenced by rndis_tx_initialise().

#define RNDIS_MTU   2048

RNDIS maximum transfer size.

This is a policy decision.

Definition at line 61 of file rndis.h.

Referenced by rndis_tx_initialise().

#define RNDIS_INITIALISE_CMPLT   0x80000002UL

RNDIS initialise completion.

Definition at line 64 of file rndis.h.

Referenced by rndis_rx_message().

#define RNDIS_HALT_MSG   0x00000003UL

RNDIS halt message.

Definition at line 91 of file rndis.h.

Referenced by rndis_tx_halt().

#define RNDIS_QUERY_MSG   0x00000004UL

RNDIS query OID message.

Definition at line 100 of file rndis.h.

Referenced by rndis_tx_oid().

#define RNDIS_SET_MSG   0x00000005UL

RNDIS set OID message.

Definition at line 103 of file rndis.h.

Referenced by rndis_tx_oid().

#define RNDIS_QUERY_CMPLT   0x80000004UL

RNDIS query OID completion.

Definition at line 120 of file rndis.h.

Referenced by rndis_rx_message().

#define RNDIS_SET_CMPLT   0x80000005UL

RNDIS set OID completion.

Definition at line 135 of file rndis.h.

Referenced by rndis_rx_message().

#define RNDIS_RESET_MSG   0x00000006UL

RNDIS reset message.

Definition at line 146 of file rndis.h.

#define RNDIS_RESET_CMPLT   0x80000006UL

RNDIS reset completion.

Definition at line 155 of file rndis.h.

#define RNDIS_INDICATE_STATUS_MSG   0x00000007UL

RNDIS indicate status message.

Definition at line 166 of file rndis.h.

Referenced by rndis_rx_message().

#define RNDIS_KEEPALIVE_MSG   0x00000008UL

RNDIS keepalive message.

Definition at line 199 of file rndis.h.

#define RNDIS_KEEPALIVE_CMPLT   0x80000008UL

RNDIS keepalive completion.

Definition at line 208 of file rndis.h.

#define RNDIS_PACKET_MSG   0x00000001UL

RNDIS packet message.

Definition at line 219 of file rndis.h.

Referenced by acm_transmit(), netvsc_transmit(), rndis_rx_message(), rndis_tx_complete_err(), rndis_tx_data(), and rndis_tx_defer().

#define RNDIS_OID_GEN_CURRENT_PACKET_FILTER   0x0001010eUL

OID for packet filter.

Definition at line 254 of file rndis.h.

Referenced by rndis_filter().

#define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS   0x00010114UL

OID for media status.

Definition at line 271 of file rndis.h.

Referenced by rndis_describe(), rndis_open(), and rndis_rx_query_oid().

#define RNDIS_OID_802_3_PERMANENT_ADDRESS   0x01010101UL

OID for permanent MAC address.

Definition at line 274 of file rndis.h.

Referenced by rndis_describe(), and rndis_rx_query_oid().

#define RNDIS_OID_802_3_CURRENT_ADDRESS   0x01010102UL

OID for current MAC address.

Definition at line 277 of file rndis.h.

Referenced by rndis_describe(), and rndis_rx_query_oid().


Enumeration Type Documentation

RNDIS status codes.

Enumerator:
RNDIS_STATUS_MEDIA_CONNECT 

Device is connected to a network medium.

RNDIS_STATUS_MEDIA_DISCONNECT 

Device is disconnected from the medium.

RNDIS_STATUS_WTF_WORLD 

Unknown start-of-day status code.

Definition at line 189 of file rndis.h.

                  {
        /** Device is connected to a network medium */
        RNDIS_STATUS_MEDIA_CONNECT = 0x4001000bUL,
        /** Device is disconnected from the medium */
        RNDIS_STATUS_MEDIA_DISCONNECT = 0x4001000cUL,
        /** Unknown start-of-day status code */
        RNDIS_STATUS_WTF_WORLD = 0x40020006UL,
};

Packet filter bits.

Enumerator:
RNDIS_FILTER_UNICAST 

Unicast packets.

RNDIS_FILTER_MULTICAST 

Multicast packets.

RNDIS_FILTER_ALL_MULTICAST 

All multicast packets.

RNDIS_FILTER_BROADCAST 

Broadcast packets.

RNDIS_FILTER_PROMISCUOUS 

All packets.

Definition at line 257 of file rndis.h.

                         {
        /** Unicast packets */
        RNDIS_FILTER_UNICAST = 0x00000001UL,
        /** Multicast packets */
        RNDIS_FILTER_MULTICAST = 0x00000002UL,
        /** All multicast packets */
        RNDIS_FILTER_ALL_MULTICAST = 0x00000004UL,
        /** Broadcast packets */
        RNDIS_FILTER_BROADCAST = 0x00000008UL,
        /** All packets */
        RNDIS_FILTER_PROMISCUOUS = 0x00000020UL
};

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void rndis_init ( struct rndis_device rndis,
struct rndis_operations op 
) [inline, static]

Initialise an RNDIS device.

Parameters:
rndisRNDIS device
opRNDIS device operations

Definition at line 339 of file rndis.h.

References rndis_device::op, and op.

Referenced by acm_probe(), and netvsc_probe().

                                                              {

        rndis->op = op;
}
void rndis_tx_complete_err ( struct rndis_device rndis,
struct io_buffer iobuf,
int  rc 
)

Complete message transmission.

Parameters:
rndisRNDIS device
iobufI/O buffer
rcPacket 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, RNDIS_PACKET_MSG, and rndis_header::type.

Referenced by acm_out_complete(), netvsc_cancel_transmit(), and rndis_tx_complete().

                                                               {
        struct net_device *netdev = rndis->netdev;
        struct rndis_header *header;
        size_t len = iob_len ( iobuf );

        /* Sanity check */
        if ( len < sizeof ( *header ) ) {
                DBGC ( rndis, "RNDIS %s completed underlength transmission:\n",
                       rndis->name );
                DBGC_HDA ( rndis, 0, iobuf->data, len );
                netdev_tx_err ( netdev, NULL, -EINVAL );
                return;
        }
        header = iobuf->data;

        /* Complete buffer */
        if ( header->type == cpu_to_le32 ( RNDIS_PACKET_MSG ) ) {
                netdev_tx_complete_err ( netdev, iobuf, rc );
        } else {
                free_iob ( iobuf );
        }
}
int rndis_tx_defer ( struct rndis_device rndis,
struct io_buffer iobuf 
)

Defer transmitted packet.

Parameters:
rndisRNDIS device
iobufI/O buffer
Return values:
rcReturn 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(), RNDIS_PACKET_MSG, and rndis_header::type.

Referenced by netvsc_transmit().

                                                                           {
        struct net_device *netdev = rndis->netdev;
        struct rndis_header *header;
        struct rndis_packet_message *msg;

        /* Fail unless this was a packet message.  Only packet
         * messages correspond to I/O buffers in the network device's
         * TX queue; other messages cannot be deferred in this way.
         */
        assert ( iob_len ( iobuf ) >= sizeof ( *header ) );
        header = iobuf->data;
        if ( header->type != cpu_to_le32 ( RNDIS_PACKET_MSG ) )
                return -ENOTSUP;

        /* Strip RNDIS header and packet message header, to return
         * this packet to the state in which we received it.
         */
        iob_pull ( iobuf, ( sizeof ( *header ) + sizeof ( *msg ) ) );

        /* Defer packet */
        netdev_tx_defer ( netdev, iobuf );

        return 0;
}
void rndis_rx ( struct rndis_device rndis,
struct io_buffer iobuf 
)

Receive packet from underlying transport layer.

Parameters:
rndisRNDIS device
iobufI/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(), rndis_header::type, and type.

Referenced by acm_control_receive(), acm_in_complete(), and netvsc_recv_data().

                                                                      {
        struct net_device *netdev = rndis->netdev;
        struct rndis_header *header;
        unsigned int type;
        int rc;

        /* Sanity check */
        if ( iob_len ( iobuf ) < sizeof ( *header ) ) {
                DBGC ( rndis, "RNDIS %s received underlength packet:\n",
                       rndis->name );
                DBGC_HDA ( rndis, 0, iobuf->data, iob_len ( iobuf ) );
                rc = -EINVAL;
                goto drop;
        }
        header = iobuf->data;

        /* Parse and strip header */
        type = le32_to_cpu ( header->type );
        iob_pull ( iobuf, sizeof ( *header ) );

        /* Handle message */
        rndis_rx_message ( rndis, iob_disown ( iobuf ), type );

        return;

 drop:
        /* Record error */
        netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
}
void rndis_rx_err ( struct rndis_device rndis,
struct io_buffer iobuf,
int  rc 
)

Discard packet from underlying transport layer.

Parameters:
rndisRNDIS device
iobufI/O buffer
rcPacket status code

Definition at line 866 of file rndis.c.

References iob_disown, netdev, rndis_device::netdev, and netdev_rx_err().

Referenced by acm_in_complete(), acm_intr_complete(), and acm_poll().

                             {
        struct net_device *netdev = rndis->netdev;

        /* Record error */
        netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
}
struct rndis_device* alloc_rndis ( size_t  priv_len) [read]

Allocate RNDIS device.

Parameters:
priv_lenLength of private data
Return values:
rndisRNDIS 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().

                                                      {
        struct net_device *netdev;
        struct rndis_device *rndis;

        /* Allocate and initialise structure */
        netdev = alloc_etherdev ( sizeof ( *rndis ) + priv_len );
        if ( ! netdev )
                return NULL;
        netdev_init ( netdev, &rndis_operations );
        rndis = netdev->priv;
        rndis->netdev = netdev;
        rndis->priv = ( ( ( void * ) rndis ) + sizeof ( *rndis ) );

        return rndis;
}
int register_rndis ( struct rndis_device rndis)

Register RNDIS device.

Parameters:
rndisRNDIS device
Return values:
rcReturn 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().

                                                  {
        struct net_device *netdev = rndis->netdev;
        int rc;

        /* Describe RNDIS device */
        if ( ( rc = rndis_describe ( rndis ) ) != 0 )
                goto err_describe;

        /* Register network device */
        if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
                DBGC ( rndis, "RNDIS %s could not register: %s\n",
                       rndis->name, strerror ( rc ) );
                goto err_register;
        }

        return 0;

        unregister_netdev ( netdev );
 err_register:
 err_describe:
        return rc;
}
void unregister_rndis ( struct rndis_device rndis)

Unregister RNDIS device.

Parameters:
rndisRNDIS 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().

                                                     {
        struct net_device *netdev = rndis->netdev;

        /* Unregister network device */
        unregister_netdev ( netdev );
}
void free_rndis ( struct rndis_device rndis)

Free RNDIS device.

Parameters:
rndisRNDIS 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().

                                               {
        struct net_device *netdev = rndis->netdev;

        /* Free network device */
        netdev_nullify ( netdev );
        netdev_put ( netdev );
}
static void rndis_tx_complete ( struct rndis_device rndis,
struct io_buffer iobuf 
) [inline, static]

Complete message transmission.

Parameters:
rndisRNDIS device
iobufI/O buffer

Definition at line 364 of file rndis.h.

References rndis_tx_complete_err().

Referenced by acm_control_transmit(), and netvsc_recv_completion().

                                                                 {

        rndis_tx_complete_err ( rndis, iobuf, 0 );
}