53 const void *
data,
size_t len ) {
60 DBGC ( netvsc,
"NETVSC %s could not send control message: %s\n",
82 DBGC ( netvsc,
"NETVSC %s timed out waiting for XRID %d\n",
119 sizeof (
msg ) ) ) != 0 ) {
120 DBGC ( netvsc,
"NETVSC %s could not initialise: %s\n",
142 if (
len <
sizeof ( *cmplt ) ) {
143 DBGC ( netvsc,
"NETVSC %s underlength initialisation " 144 "completion (%zd bytes)\n", netvsc->
name,
len );
148 DBGC ( netvsc,
"NETVSC %s unexpected initialisation completion " 149 "type %d\n", netvsc->
name,
154 DBGC ( netvsc,
"NETVSC %s initialisation failure status %d\n",
180 &
msg,
sizeof (
msg ) ) ) != 0 ) {
181 DBGC ( netvsc,
"NETVSC %s could not set NDIS version: %s\n",
209 sizeof (
msg ) ) ) != 0 ) {
210 DBGC ( netvsc,
"NETVSC %s could not establish buffer: %s\n",
227 const void *
data,
size_t len ) {
231 if (
len <
sizeof ( *cmplt ) ) {
232 DBGC ( netvsc,
"NETVSC %s underlength buffer completion (%zd " 233 "bytes)\n", netvsc->
name,
len );
237 DBGC ( netvsc,
"NETVSC %s unexpected buffer completion type " 242 DBGC ( netvsc,
"NETVSC %s buffer failure status %d\n",
268 if ( netvsc_is_obsolete ( netvsc ) )
278 &
msg, sizeof (
msg ) ) ) != 0 ) {
279 DBGC ( netvsc,
"NETVSC %s could not revoke buffer: %s\n",
297 const void *
data,
size_t len ) {
301 DBGC ( netvsc,
"NETVSC %s received unsupported control packet " 302 "(%08llx):\n", netvsc->
name, xid );
328 if (
len <
sizeof ( *
msg ) ) {
329 DBGC ( netvsc,
"NETVSC %s received underlength RNDIS packet " 330 "(%zd bytes)\n", netvsc->
name,
len );
335 DBGC ( netvsc,
"NETVSC %s received unexpected RNDIS packet " 336 "type %d\n", netvsc->
name,
344 DBGC ( netvsc,
"NETVSC %s could not send completion: %s\n",
376 const void *
data,
size_t len ) {
381 const void *
data,
size_t len );
394 ( netvsc->
tx.
count - 1 ) ] = tx_id;
406 }
else if ( ( netvsc->
wait_xrid != 0 ) &&
410 DBGC ( netvsc,
"NETVSC %s received unexpected completion " 411 "(%08llx)\n", netvsc->
name, xid );
439 DBGC ( netvsc,
"NETVSC %s received unsupported cancellation packet " 440 "(%08llx):\n", netvsc->
name, xid );
491 if ( netvsc_is_obsolete ( netvsc ) )
499 if ( netvsc_ring_is_full ( &netvsc->
tx ) )
518 DBGC ( netvsc,
"NETVSC %s could not send RNDIS message: %s\n",
539 unsigned int tx_id ) {
546 DBGC ( netvsc,
"NETVSC %s cancelling transmission %#x\n",
547 netvsc->
name, tx_id );
566 for ( i = 0 ; i < ring->
count ; i++ ) {
592 for ( i = 0 ; i < ring->
count ; i++ ) {
599 discard ( netvsc, iobuf, i );
603 assert ( netvsc_ring_is_empty ( ring ) );
651 DBGC ( netvsc,
"NETVSC %s could not allocate %zd-byte buffer\n",
661 DBGC ( netvsc,
"NETVSC %s could not establish GPADL: %s\n",
663 goto err_establish_gpadl;
669 DBGC ( netvsc,
"NETVSC %s could not register transfer pages: " 671 goto err_register_pages;
701 DBGC ( netvsc,
"NETVSC %s could not tear down GPADL: %s\n",
732 DBGC ( netvsc,
"NETVSC %s could not open VMBus: %s\n",
741 goto err_ndis_version;
749 goto err_establish_rx;
814 netvsc = rndis->
priv;
815 netvsc->
vmdev = vmdev;
816 netvsc->
rndis = rndis;
829 DBGC ( netvsc,
"NETVSC %s could not register: %s\n",
864 DBGC ( netvsc,
"NETVSC %s could not reopen: %s\n",
890 .type =
VMBUS_TYPE ( 0xf8615163, 0xdf3e, 0x46c5, 0x913f,
891 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0x0e ),
struct rndis_device * alloc_rndis(size_t priv_len)
Allocate RNDIS device.
unsigned int count
Number of descriptors.
#define EINVAL
Invalid argument.
static int netvsc_create_ring(struct netvsc_device *netvsc __unused, struct netvsc_ring *ring)
Create descriptor ring.
static int netvsc_transmit(struct rndis_device *rndis, struct io_buffer *iobuf)
Transmit packet.
NetVSC initialisation message.
struct arbelprm_rc_send_wqe rc
int vmbus_send_completion(struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len)
Send completion packet via ring buffer.
#define NETVSC_RX_ESTABLISH_CMPLT
NetVSC establish receive data buffer completion.
static struct vmbus_channel_operations netvsc_channel_operations
VMBus channel operations.
struct device dev
Generic iPXE device.
static int vmbus_has_data(struct vmbus_device *vmdev)
Check if data is present in ring buffer.
int(* open)(struct rndis_device *rndis)
Open RNDIS device.
#define NETVSC_RNDIS_DATA
RNDIS data channel (for RNDIS_PACKET_MSG only)
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
static void netvsc_poll(struct rndis_device *rndis)
Poll for completed and received packets.
pseudo_bit_t completion[0x00001]
static void netvsc_close(struct rndis_device *rndis)
Close device.
static void netvsc_cancel_transmit(struct netvsc_device *netvsc, struct io_buffer *iobuf, unsigned int tx_id)
Cancel transmission.
#define le32_to_cpu(value)
int(* recv_control)(struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len)
Handle received control packet.
static void netvsc_destroy_ring(struct netvsc_device *netvsc, struct netvsc_ring *ring, void(*discard)(struct netvsc_device *, struct io_buffer *, unsigned int))
Destroy descriptor ring.
struct vmbus_driver netvsc_driver __vmbus_driver
NetVSC driver.
static void rndis_tx_complete(struct rndis_device *rndis, struct io_buffer *iobuf)
Complete message transmission.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
int vmbus_open(struct vmbus_device *vmdev, struct vmbus_channel_operations *op, size_t out_len, size_t in_len, size_t mtu)
Open VMBus channel.
#define EPIPE
Broken pipe.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
void unregister_rndis(struct rndis_device *rndis)
Unregister RNDIS device.
#define NETVSC_VERSION_1
Oldest known NetVSC protocol version.
static int netvsc_establish_buffer(struct netvsc_device *netvsc, struct netvsc_buffer *buffer)
Establish data buffer.
unsigned long long uint64_t
#define NETVSC_RNDIS_MSG
NetVSC RNDIS message.
Establish receive buffer.
unsigned int id_cons
Buffer ID consumer counter.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
static int netvsc_recv_cancellation(struct vmbus_device *vmdev, uint64_t xid)
Handle received cancellation packet.
#define PAGE_SIZE
Page size.
struct netvsc_header header
Message header.
NetVSC establish receive data buffer completion.
static void netvsc_remove(struct vmbus_device *vmdev)
Remove device.
#define NETVSC_RX_REVOKE_MSG
NetVSC revoke receive data buffer message.
#define ECANCELED
Operation canceled.
#define ENOTSUP
Operation not supported.
#define NETVSC_RX_BUF_PAGESET
RX data buffer page set ID.
A doubly-linked list entry (or list head)
static int vmbus_register_pages(struct vmbus_device *vmdev, struct vmbus_xfer_pages *pages)
Register transfer page set.
Hyper-V network virtual service client.
#define NETVSC_NDIS_MINOR
NetVSC NDIS minor version.
Hyper-V virtual machine bus.
static int netvsc_revoke_buffer(struct netvsc_device *netvsc, struct netvsc_buffer *buffer)
Revoke data buffer.
#define list_del(list)
Delete an entry from a list.
#define ENOMEM
Not enough space.
#define iob_disown(iobuf)
Disown an I/O buffer.
struct io_buffer ** iobufs
I/O buffers, indexed by buffer ID.
#define __unused
Declare a variable or data structure as unused.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned int id_prod
Buffer ID producer counter.
#define NETVSC_MAX_WAIT_MS
Maximum time to wait for a transaction to complete.
#define container_of(ptr, type, field)
Get containing structure.
struct net_device * netdev
Network device.
NetVSC establish data buffer message.
static int netvsc_recv_completion(struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len)
Handle received completion packet.
#define NETVSC_RNDIS_NO_BUFFER
"No buffer used" index
#define NETVSC_RX_ESTABLISH_MSG
NetVSC establish receive data buffer message.
static int netvsc_recv_control(struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len)
Handle received control packet.
static struct net_device * netdev
struct netvsc_ring tx
Transmit ring.
#define NETVSC_INIT_CMPLT
NetVSC initialisation completion.
static int netvsc_buffer_copy(struct vmbus_xfer_pages *pages, void *data, size_t offset, size_t len)
Copy data from data buffer.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
static struct rndis_operations netvsc_operations
RNDIS operations.
#define cpu_to_le32(value)
#define EPROTO
Protocol error.
#define ERANGE
Result too large.
char * strerror(int errno)
Retrieve string representation of error number.
int register_rndis(struct rndis_device *rndis)
Register RNDIS device.
static void * vmbus_get_drvdata(struct vmbus_device *vmdev)
Get VMBus device driver-private data.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static int netvsc_open(struct rndis_device *rndis)
Open device.
#define NETVSC_MTU
Maximum supported NetVSC message length.
static int netvsc_ndis_version(struct netvsc_device *netvsc)
Set NDIS version.
static int netvsc_completed(struct netvsc_device *netvsc __unused, const void *data __unused, size_t len __unused)
Handle generic completion.
Remote Network Driver Interface Specification.
static void vmbus_unregister_pages(struct vmbus_device *vmdev, struct vmbus_xfer_pages *pages)
Unregister transfer page set.
int vmbus_gpadl_teardown(struct vmbus_device *vmdev, unsigned int gpadl)
Tear down GPA descriptor list.
#define NETVSC_NDIS_MAJOR
NetVSC NDIS major version.
void rndis_rx(struct rndis_device *rndis, struct io_buffer *iobuf)
Receive packet from underlying transport layer.
struct vmbus_xfer_pages pages
Transfer page set.
static int netvsc_rx_established_buffer(struct netvsc_device *netvsc, const void *data, size_t len)
Handle establish receive data buffer completion.
static void rndis_init(struct rndis_device *rndis, struct rndis_operations *op)
Initialise an RNDIS device.
struct io_buffer * tx_iobufs[NETVSC_TX_NUM_DESC]
Transmit I/O buffers.
#define NETVSC_NDIS_VERSION_MSG
NetVSC NDIS version message.
#define NETVSC_TX_NUM_DESC
Number of transmit ring entries.
int(* copy)(struct vmbus_xfer_pages *pages, void *data, size_t offset, size_t len)
Copy data from transfer page.
int rndis_tx_defer(struct rndis_device *rndis, struct io_buffer *iobuf)
Defer transmitted packet.
struct device * dev
Underlying hardware device.
int vmbus_send_cancellation(struct vmbus_device *vmdev, uint64_t xid)
Send cancellation packet via ring buffer.
void netdev_close(struct net_device *netdev)
Close network device.
int vmbus_poll(struct vmbus_device *vmdev)
Poll ring buffer.
uint8_t tx_ids[NETVSC_TX_NUM_DESC]
Transmit buffer IDs.
unsigned int wait_xrid
Relative transaction ID for current blocking transaction.
A NetVSC descriptor ring.
#define VMBUS_TYPE(a, b, c, d, e0, e1, e2, e3, e4, e5)
Construct VMBus type.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
VMBus transfer page set operations.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int vmbus_send_control(struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len)
Send control packet via ring buffer.
struct vmbus_device * vmdev
VMBus device.
struct list_head list
List of which this buffer is a member.
static __always_inline void ufree(userptr_t userptr)
Free external memory.
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
static int netvsc_reset(struct vmbus_device *vmdev)
Reset device.
static void netvsc_destroy_buffer(struct netvsc_device *netvsc, struct netvsc_buffer *buffer)
Destroy data buffer.
VMBus channel operations.
void * data
Start of data.
void * priv
Driver private data.
struct ena_aq_header header
Header.
#define RNDIS_PACKET_MSG
RNDIS packet message.
uint8_t data[48]
Additional event data.
NetVSC NDIS version message.
static int netvsc_initialised(struct netvsc_device *netvsc, const void *data, size_t len)
Handle initialisation completion.
static int netvsc_probe(struct vmbus_device *vmdev)
Probe device.
uint16_t offset
Offset to command line.
#define NETVSC_BASE_XID
Base transaction ID.
static int netvsc_control(struct netvsc_device *netvsc, unsigned int xrid, const void *data, size_t len)
Send control message and wait for completion.
NetVSC revoke data buffer message.
VMBus "GPADL teardown" message.
void vmbus_close(struct vmbus_device *vmdev)
Close VMBus channel.
Transmit descriptors (one per transmit buffer ID)
#define NETVSC_RX_BUF_LEN
RX data buffer length.
#define NETVSC_INIT_MSG
NetVSC initialisation message.
static void vmbus_set_drvdata(struct vmbus_device *vmdev, void *priv)
Set VMBus device driver-private data.
int vmbus_establish_gpadl(struct vmbus_device *vmdev, userptr_t data, size_t len)
Establish GPA descriptor list.
static struct vmbus_xfer_pages_operations netvsc_xfer_pages_operations
Transfer page set operations.
void vmbus_dump_channel(struct vmbus_device *vmdev)
Dump channel status (for debugging)
static int netvsc_initialise(struct netvsc_device *netvsc)
Initialise communication.
struct rndis_device * rndis
RNDIS device.
void free_rndis(struct rndis_device *rndis)
Free RNDIS device.
void rndis_tx_complete_err(struct rndis_device *rndis, struct io_buffer *iobuf, int rc)
Complete message transmission.
#define NULL
NULL pointer (VOID *)
int vmbus_send_data(struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len, struct io_buffer *iobuf)
Send data packet via ring buffer.
struct netvsc_header header
Message header.
#define ETIMEDOUT
Connection timed out.
NetVSC initialisation completion.
struct netvsc_buffer rx
Receive buffer.
int netdev_open(struct net_device *netdev)
Open network device.
int wait_rc
Return status code for current blocking transaction.
#define NETVSC_RNDIS_CONTROL
RNDIS control channel (for all other RNDIS messages)
static int netvsc_recv_data(struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len, struct list_head *list)
Handle received data packet.
static int netvsc_create_buffer(struct netvsc_device *netvsc, struct netvsc_buffer *buffer)
Create data buffer.
uint8_t * ids
Buffer ID ring.
void * memset(void *dest, int character, size_t len) __nonnull