45 { .
name =
"ncm.intr" };
53 { .
name =
"ncm.in_dgram" };
57 { .
name =
"ncm.out" };
90 DBGC ( ncm,
"NCM %p interrupt failed: %s\n",
98 DBGC ( ncm,
"NCM %p underlength interrupt:\n", ncm );
110 DBGC ( ncm,
"NCM %p link up\n", ncm );
113 DBGC ( ncm,
"NCM %p link down\n", ncm );
123 DBGC ( ncm,
"NCM %p unrecognised interrupt:\n", ncm );
191 DBGC ( ncm,
"NCM %p could not prefill %dx %zd-byte " 192 "buffers for bulk IN\n", ncm,
count,
mtu );
196 DBGC ( ncm,
"NCM %p using %dx %zd-byte buffers for bulk IN\n",
201 DBGC ( ncm,
"NCM %p could not prefill bulk IN endpoint\n", ncm );
221 unsigned int remaining;
238 DBGC ( ncm,
"NCM %p bulk IN failed: %s\n",
245 if (
sizeof ( *nth ) >
len ) {
246 DBGC ( ncm,
"NCM %p packet too short for NTH:\n", ncm );
254 if ( ( ndp_offset +
sizeof ( *ndp ) ) >
len ) {
255 DBGC ( ncm,
"NCM %p packet too short for NDP:\n", ncm );
259 ndp = ( iobuf->
data + ndp_offset );
262 DBGC ( ncm,
"NCM %p NDP header length too short:\n", ncm );
266 if ( ( ndp_offset + ndp_len ) >
len ) {
267 DBGC ( ncm,
"NCM %p packet too short for NDP:\n", ncm );
274 sizeof ( ndp->
desc[0] ) );
275 for (
desc = ndp->
desc ; remaining &&
desc->offset ; remaining-- ) {
284 DBGC ( ncm,
"NCM %p underlength datagram:\n", ncm );
289 DBGC ( ncm,
"NCM %p datagram exceeds packet:\n", ncm );
360 size_t header_len = (
sizeof ( *header ) + ncm->
padding );
380 sizeof (
header->desc ) );
450 sizeof (
size ) ) ) != 0 ) {
451 DBGC ( ncm,
"NCM %p could not set input size to %zd: %s\n",
453 goto err_set_ntb_input_size;
460 DBGC ( ncm,
"NCM %p could not set MAC address: %s\n",
467 DBGC ( ncm,
"NCM %p could not open: %s\n",
476 err_set_ntb_input_size:
561 unsigned int remainder;
562 unsigned int divisor;
574 memset ( ncm, 0,
sizeof ( *ncm ) );
581 DBGC ( ncm,
"NCM %p on %s\n", ncm, func->
name );
585 DBGC ( ncm,
"NCM %p could not describe: %s\n",
595 DBGC ( ncm,
"NCM %p has no Ethernet descriptor\n", ncm );
602 DBGC ( ncm,
"NCM %p could not fetch MAC address: %s\n",
610 sizeof ( params ) ) ) != 0 ) {
611 DBGC ( ncm,
"NCM %p could not get NTB parameters: %s\n",
613 goto err_ntb_parameters;
618 DBGC2 ( ncm,
"NCM %p maximum IN size is %zd bytes\n", ncm, ncm->
mtu );
626 DBGC2 ( ncm,
"NCM %p using %zd-byte transmit padding\n",
629 ETH_HLEN ) % divisor ) == remainder );
#define EINVAL
Invalid argument.
#define NCM_IN_MIN_SIZE
Bulk IN ring minimum total buffer size.
struct arbelprm_rc_send_wqe rc
#define iob_put(iobuf, len)
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
An Ethernet Functional Descriptor.
unsigned int comms
Communications interface.
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
uint8_t ll_addr_len
Link-layer address length.
CDC-ECM USB Ethernet driver.
size_t mtu
Maximum supported NTB input size.
static int ncm_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint16_t remainder
Alignment remainder.
CDC-NCM datagram pointer (16-bit)
#define NCM_GET_NTB_PARAMETERS
Get NTB parameters.
#define iob_push(iobuf, len)
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
CDC-NCM USB Ethernet driver.
struct arbelprm_completion_with_error error
uint8_t size
Entry size (in 32-bit words)
size_t len
Refill buffer payload length.
static int ncm_in_prefill(struct ncm_device *ncm)
Prefill bulk IN endpoint.
uint64_t desc
Microcode descriptor list physical address.
#define USB_SUBCLASS_CDC_NCM
CDC-NCM subclass.
struct ncm_ntb_datagram_parameters in
IN datagram parameters.
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
int usb_prefill(struct usb_endpoint *ep)
Prefill endpoint recycled buffer list.
struct usb_driver ncm_driver __usb_driver
CDC-NCM driver.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
struct ncm_ntb_datagram_parameters out
OUT datagram parameters.
#define offsetof(type, field)
Get offset of a field within a structure.
A data structure for storing profiling information.
int open
Endpoint is open.
static void profile_stop(struct profiler *profiler)
Stop profiling.
uint32_t mtu
Maximum size.
struct usb_endpoint intr
Interrupt endpoint.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
struct ncm_datagram_descriptor desc[0]
Datagram descriptors.
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
static void ncm_poll(struct net_device *netdev)
Poll for completed and received packets.
#define NCM_MIN_NTB_INPUT_SIZE
Minimum allowed NTB input size.
static void ncm_intr_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete interrupt transfer.
struct usb_endpoint out
Bulk OUT endpoint.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static struct usb_endpoint_driver_operations ncm_in_operations
Bulk IN endpoint operations.
#define ENOMEM
Not enough space.
uint16_t sequence
Transmitted packet sequence number.
#define iob_disown(iobuf)
Disown an I/O buffer.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define NCM_SET_NTB_INPUT_SIZE
Set NTB input size.
A USB interface descriptor.
struct usb_port * port
USB port.
static void usb_recycle(struct usb_endpoint *ep, struct io_buffer *iobuf)
Recycle I/O buffer.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define container_of(ptr, type, field)
Get containing structure.
static int ncm_open(struct net_device *netdev)
Open network device.
struct net_device * netdev
Network device.
void * priv
Driver private data.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
uint16_t header_len
Header length.
#define NCM_IN_MIN_COUNT
Bulk IN ring minimum buffer count.
CDC-NCM datagram descriptor (16-bit)
struct ecm_ethernet_descriptor * ecm_ethernet_descriptor(struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface)
Locate Ethernet functional descriptor.
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
static struct net_device * netdev
struct usb_device * usb
USB device.
uint16_t count
Number of entries.
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
static void profile_start(struct profiler *profiler)
Start profiling.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
#define NCM_MAX_NTB_INPUT_SIZE
Maximum allowed NTB input size (16-bit)
static void ncm_close(struct net_device *netdev)
Close network device.
static int ncm_out_transmit(struct ncm_device *ncm, struct io_buffer *iobuf)
Transmit packet.
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
#define cpu_to_le32(value)
#define NCM_IN_MAX_SIZE
Bulk IN ring maximum total buffer size.
struct usb_interface_descriptor * usb_interface_descriptor(struct usb_configuration_descriptor *config, unsigned int interface, unsigned int alternate)
Locate USB interface descriptor.
#define CDC_NETWORK_CONNECTION
Network connection notification.
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
#define iob_unput(iobuf, len)
#define CDC_CONNECTION_SPEED_CHANGE
Connection speed change notification.
#define NCM_DATAGRAM_POINTER_MAGIC_CRC
CDC-NCM datagram pointer CRC present flag.
char * strerror(int errno)
Retrieve string representation of error number.
int register_netdev(struct net_device *netdev)
Register network device.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
struct usbnet_device usbnet
USB network device.
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
struct usb_endpoint in
Bulk IN endpoint.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
uint16_t divisor
Alignment divisor.
struct usb_device * usb
USB device.
#define NCM_SET_NET_ADDRESS
Set MAC address.
#define le16_to_cpu(value)
A CDC-NCM network device.
#define USB_CLASS_CDC
Class code for communications devices.
Network device operations.
static struct usb_endpoint_driver_operations ncm_out_operations
Bulk OUT endpoint operations.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
Network device management.
#define iob_reserve(iobuf, len)
A USB configuration descriptor.
static void ncm_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
static struct net_device_operations ncm_operations
CDC-NCM network device operations.
#define USB_ANY_ID
Match-anything ID.
Universal Serial Bus (USB)
static void usbnet_init(struct usbnet_device *usbnet, struct usb_function *func, struct usb_endpoint_driver_operations *intr, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB network device.
void * data
Start of data.
struct usb_hub * hub
USB hub.
static void ncm_remove(struct usb_function *func)
Remove device.
int ecm_fetch_mac(struct usb_function *func, struct ecm_ethernet_descriptor *desc, struct net_device *netdev)
Get hardware MAC address.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
static int ncm_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
struct ena_aq_header header
Header.
#define cpu_to_le16(value)
#define NCM_DATAGRAM_POINTER_MAGIC
CDC-NCM datagram pointer magic.
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
static struct usb_device_id ncm_ids[]
CDC-NCM device IDs.
typeof(acpi_finder=acpi_find)
ACPI table finder.
void usb_flush(struct usb_endpoint *ep)
Discard endpoint recycled buffer list.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
static struct profiler ncm_intr_profiler __profiler
Interrupt completion profiler.
char message[VMCONSOLE_BUFSIZE]
static void ncm_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
USB endpoint driver operations.
#define NCM_TRANSFER_HEADER_MAGIC
CDC-NCM transfer header magic.
struct device dev
Generic device.
struct usb_bus * bus
USB bus.
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
size_t padding
Alignment padding required on transmitted packets.
#define NULL
NULL pointer (VOID *)
static struct usb_endpoint_driver_operations ncm_intr_operations
Interrupt endpoint operations.
#define NCM_INTR_COUNT
Interrupt ring buffer count.
struct ll_protocol * ll_protocol
Link-layer protocol.
struct usb_bus * bus
USB bus.
struct usb_device_id * ids
USB ID table.
void * memset(void *dest, int character, size_t len) __nonnull
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.