FreeBSD kernel /amd64 XEN device code
|
Device driver supporting the vending of network access from this FreeBSD domain to other domains. More...
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_inet6.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/rman.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/if_ether.h>
#include <netinet/tcp.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <machine/in_cksum.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
#include <machine/_inttypes.h>
#include <xen/xen-os.h>
#include <xen/hypervisor.h>
#include <xen/xen_intr.h>
#include <contrib/xen/io/netif.h>
#include <xen/xenbus/xenbusvar.h>
#include "netback_unit_tests.c"
Go to the source code of this file.
Data Structures | |
struct | xnb_pkt |
struct | xnb_ring_config |
Configuration data for a shared memory request ring used to communicate with the front-end client of this this driver. More... | |
struct | xnb_softc |
Macros | |
#define | XNB_SG 1 /* netback driver supports feature-sg */ |
#define | XNB_GSO_TCPV4 0 /* netback driver supports feature-gso-tcpv4 */ |
#define | XNB_RX_COPY 1 /* netback driver supports feature-rx-copy */ |
#define | XNB_RX_FLIP 0 /* netback driver does not support feature-rx-flip */ |
#define | XNB_DEBUG /* hardcode on during development */ |
#define | DPRINTF(fmt, args...) printf("xnb(%s:%d): " fmt, __FUNCTION__, __LINE__, ##args) |
#define | GNTTAB_LEN (64) |
#define | XNB_CSUM_FEATURES (CSUM_TCP | CSUM_UDP) |
#define | NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE) |
#define | NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE) |
#define | RING_HAS_UNCONSUMED_REQUESTS_2(_r, cons) |
#define | virt_to_mfn(x) (vtophys(x) >> PAGE_SHIFT) |
#define | virt_to_offset(x) ((x) & (PAGE_SIZE - 1)) |
Typedefs | |
typedef struct gnttab_copy | gnttab_copy_table[GNTTAB_LEN] |
Enumerations | |
enum | xnb_flag_t { XNBF_RING_CONNECTED = 0x01 , XNBF_RESOURCE_SHORTAGE = 0x02 , XNBF_SHUTDOWN = 0x04 , XNBF_IN_SHUTDOWN = 0x08 } |
enum | xnb_ring_type_t { XNB_RING_TYPE_TX = 0 , XNB_RING_TYPE_RX = 1 , XNB_NUM_RING_TYPES } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_XENNETBACK, "xnb", "Xen Net Back Driver Data") |
static void | xnb_attach_failed (struct xnb_softc *xnb, int err, const char *fmt,...) __printflike(3 |
static void static int | xnb_shutdown (struct xnb_softc *xnb) |
static int | create_netdev (device_t dev) |
static int | xnb_detach (device_t dev) |
static int | xnb_ifmedia_upd (struct ifnet *ifp) |
static void | xnb_ifmedia_sts (struct ifnet *ifp, struct ifmediareq *ifmr) |
static void | xnb_intr (void *arg) |
static int | xnb_send (netif_rx_back_ring_t *rxb, domid_t otherend, const struct mbuf *mbufc, gnttab_copy_table gnttab) |
static int | xnb_recv (netif_tx_back_ring_t *txb, domid_t otherend, struct mbuf **mbufc, struct ifnet *ifnet, gnttab_copy_table gnttab) |
static int | xnb_ring2pkt (struct xnb_pkt *pkt, const netif_tx_back_ring_t *tx_ring, RING_IDX start) |
static void | xnb_txpkt2rsp (const struct xnb_pkt *pkt, netif_tx_back_ring_t *ring, int error) |
static struct mbuf * | xnb_pkt2mbufc (const struct xnb_pkt *pkt, struct ifnet *ifp) |
static int | xnb_txpkt2gnttab (const struct xnb_pkt *pkt, struct mbuf *mbufc, gnttab_copy_table gnttab, const netif_tx_back_ring_t *txb, domid_t otherend_id) |
static void | xnb_update_mbufc (struct mbuf *mbufc, const gnttab_copy_table gnttab, int n_entries) |
static int | xnb_mbufc2pkt (const struct mbuf *mbufc, struct xnb_pkt *pkt, RING_IDX start, int space) |
static int | xnb_rxpkt2gnttab (const struct xnb_pkt *pkt, const struct mbuf *mbufc, gnttab_copy_table gnttab, const netif_rx_back_ring_t *rxb, domid_t otherend_id) |
static int | xnb_rxpkt2rsp (const struct xnb_pkt *pkt, const gnttab_copy_table gnttab, int n_entries, netif_rx_back_ring_t *ring) |
static void | xnb_stop (struct xnb_softc *) |
static int | xnb_ioctl (struct ifnet *, u_long, caddr_t) |
static void | xnb_start_locked (struct ifnet *) |
static void | xnb_start (struct ifnet *) |
static void | xnb_ifinit_locked (struct xnb_softc *) |
static void | xnb_ifinit (void *) |
static int | xnb_unit_test_main (SYSCTL_HANDLER_ARGS) |
static int | xnb_dump_rings (SYSCTL_HANDLER_ARGS) |
static void | xnb_pkt_initialize (struct xnb_pkt *pxnb) |
static void | xnb_pkt_validate (struct xnb_pkt *pxnb) |
static void | xnb_pkt_invalidate (struct xnb_pkt *pxnb) |
static int | xnb_pkt_is_valid (const struct xnb_pkt *pxnb) |
static void __unused | xnb_dump_pkt (const struct xnb_pkt *pkt) |
static void | xnb_dump_txreq (RING_IDX idx, const struct netif_tx_request *txreq) |
static void __unused | xnb_dump_gnttab_copy (const struct gnttab_copy *entry) |
static void __unused | xnb_dump_mbuf (const struct mbuf *m) |
static void | xnb_free_communication_mem (struct xnb_softc *xnb) |
static int | xnb_disconnect (struct xnb_softc *xnb) |
static int | xnb_connect_ring (struct xnb_softc *xnb, xnb_ring_type_t ring_type) |
static int | xnb_connect_comms (struct xnb_softc *xnb) |
static int | xnb_alloc_communication_mem (struct xnb_softc *xnb) |
static int | xnb_collect_xenstore_info (struct xnb_softc *xnb) |
static int | xnb_publish_backend_info (struct xnb_softc *xnb) |
static void | xnb_connect (struct xnb_softc *xnb) |
static int | xnb_probe (device_t dev) |
static void | xnb_setup_sysctl (struct xnb_softc *xnb) |
static int | xnb_attach (device_t dev) |
static int | xnb_suspend (device_t dev) |
static int | xnb_resume (device_t dev) |
static void | xnb_frontend_changed (device_t dev, XenbusState frontend_state) |
DRIVER_MODULE (xnb, xenbusb_back, xnb_driver, xnb_devclass, 0, 0) | |
Variables | |
static device_method_t | xnb_methods [] |
static driver_t | xnb_driver |
devclass_t | xnb_devclass |
Device driver supporting the vending of network access from this FreeBSD domain to other domains.
Definition in file netback.c.
#define DPRINTF | ( | fmt, | |
args... | |||
) | printf("xnb(%s:%d): " fmt, __FUNCTION__, __LINE__, ##args) |
#define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE) |
#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE) |
#define RING_HAS_UNCONSUMED_REQUESTS_2 | ( | _r, | |
cons | |||
) |
#define XNB_GSO_TCPV4 0 /* netback driver supports feature-gso-tcpv4 */ |
#define XNB_RX_COPY 1 /* netback driver supports feature-rx-copy */ |
#define XNB_RX_FLIP 0 /* netback driver does not support feature-rx-flip */ |
typedef struct gnttab_copy gnttab_copy_table[GNTTAB_LEN] |
enum xnb_flag_t |
Per-instance connection state flags.
enum xnb_ring_type_t |
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Create a network device.
handle | device handle |
Definition at line 1181 of file netback.c.
References xnb_softc::carrier, xnb_softc::dev, xnb_softc::handle, xnb_softc::if_name, ifp, xnb_softc::mac, NET_RX_RING_SIZE, xnb_softc::rx_lock, xnb_softc::sc_lock, xnb_softc::sc_media, xnb_softc::tx_lock, XNB_CSUM_FEATURES, xnb_ifinit(), xnb_ifmedia_sts(), xnb_ifmedia_upd(), xnb_softc::xnb_ifp, xnb_ioctl(), xnb_start(), and xs_scanf().
Referenced by xnb_attach().
DRIVER_MODULE | ( | xnb | , |
xenbusb_back | , | ||
xnb_driver | , | ||
xnb_devclass | , | ||
0 | , | ||
0 | |||
) |
|
static |
Custom malloc type for all driver allocations.
|
static |
Size KVA and pseudo-physical address allocations based on negotiated values for the size and number of I/O requests, and the size of our communication ring.
xnb | Per-instance xnb configuration structure. |
These address spaces are used to dynamically map pages in the front-end's domain into our own.
Definition at line 803 of file netback.c.
References xnb_softc::dev, xnb_softc::gnt_base_addr, xnb_softc::kva, xnb_softc::kva_size, xnb_softc::pseudo_phys_res, xnb_softc::pseudo_phys_res_id, xnb_softc::ring_configs, xnb_ring_config::ring_pages, xenmem_alloc(), and XNB_NUM_RING_TYPES.
Referenced by xnb_connect().
|
static |
Attach to a XenBus device that has been claimed by our probe routine.
dev | NewBus device object representing this Xen Net Back instance. |
Definition at line 1255 of file netback.c.
References create_netdev(), xnb_softc::dev, DPRINTF, xnb_softc::otherend_id, xnb_softc::ring_configs, xnb_ring_config::ring_pages, xnb_attach_failed(), XNB_NUM_RING_TYPES, xnb_publish_backend_info(), xnb_setup_sysctl(), and xs_printf().
|
static |
Report an attach time error to the console and Xen, and cleanup this instance by forcing immediate detach processing.
xnb | Per-instance xnb configuration structure. |
err | Errno describing the error. |
fmt | Printf style format and arguments |
Definition at line 1090 of file netback.c.
References xnb_softc::dev, xnb_detach(), xs_printf(), and xs_vprintf().
Referenced by xnb_attach().
|
static |
Collect information from the XenStore related to our device and its frontend
xnb | Per-instance xnb configuration structure. |
Definition at line 837 of file netback.c.
References xnb_softc::bridge, xnb_softc::can_sg, xnb_softc::dev, xnb_softc::evtchn, xnb_softc::gso, xnb_softc::gso_prefix, xnb_softc::handle, xnb_softc::ip_csum, xnb_softc::ring_configs, xnb_ring_config::ring_ref, XNB_RING_TYPE_RX, XNB_RING_TYPE_TX, xs_gather(), xs_read(), and xs_scanf().
Referenced by xnb_connect().
|
static |
Connect to our netfront peer now that it has completed publishing its configuration into the XenStore.
xnb | Per-instance xnb configuration structure. |
Definition at line 995 of file netback.c.
References xnb_softc::carrier, xnb_softc::dev, xnb_softc::flags, xnb_alloc_communication_mem(), xnb_collect_xenstore_info(), and xnb_connect_comms().
Referenced by xnb_frontend_changed().
|
static |
Setup the shared memory rings and bind an interrupt to the event channel used to notify us of ring changes.
xnb | Per-instance xnb configuration structure. |
Definition at line 754 of file netback.c.
References xnb_softc::dev, DPRINTF, xnb_softc::evtchn, xnb_softc::flags, xnb_softc::otherend_id, xnb_softc::xen_intr_handle, xnb_connect_ring(), xnb_disconnect(), xnb_intr(), XNB_NUM_RING_TYPES, and XNBF_RING_CONNECTED.
Referenced by xnb_connect().
|
static |
Map a single shared memory ring into domain local address space and initialize its control structure
xnb | Per-instance xnb configuration structure |
ring_type | Array index of this ring in the xnb's array of rings |
Definition at line 701 of file netback.c.
References xnb_ring_config::back_ring, xnb_ring_config::bus_addr, xnb_softc::dev, xnb_ring_config::gnt_addr, xnb_softc::gnt_base_addr, xnb_ring_config::handle, xnb_softc::kva, xnb_softc::otherend_id, xnb_softc::ring_configs, xnb_ring_config::ring_pages, xnb_ring_config::ring_ref, xnb_ring_config::rx_ring, xnb_ring_config::tx_ring, xnb_ring_config::va, XNB_RING_TYPE_RX, and XNB_RING_TYPE_TX.
Referenced by xnb_connect_comms().
|
static |
Detach from a net back device instance.
dev | NewBus device object representing this Xen Net Back instance. |
Definition at line 1326 of file netback.c.
References xnb_softc::dev, DPRINTF, xnb_softc::rx_lock, xnb_softc::sc_lock, xnb_softc::tx_lock, and xnb_shutdown().
Referenced by xnb_attach_failed().
|
static |
Cleanup all inter-domain communication mechanisms.
xnb | Per-instance xnb configuration structure. |
Definition at line 639 of file netback.c.
References xnb_softc::bridge, xnb_ring_config::bus_addr, xnb_softc::flags, xnb_ring_config::gnt_addr, xnb_ring_config::handle, xnb_softc::ring_configs, xnb_softc::rx_lock, xnb_softc::sc_lock, xnb_softc::tx_lock, xnb_softc::xen_intr_handle, xnb_free_communication_mem(), XNB_NUM_RING_TYPES, XNB_RING_TYPE_RX, and XNB_RING_TYPE_TX.
Referenced by xnb_connect_comms(), and xnb_shutdown().
|
static |
|
static |
|
static |
xnb_pkt method: print the packet's contents in human-readable format
Definition at line 278 of file netback.c.
References xnb_pkt::car, xnb_pkt::car_size, xnb_pkt::cdr, DPRINTF, xnb_pkt::error, xnb_pkt::flags, xnb_pkt::list_len, and xnb_pkt::size.
|
static |
Definition at line 540 of file netback.c.
References xnb_ring_config::back_ring, xnb_softc::ring_configs, xnb_ring_config::rx_ring, rxb, xnb_ring_config::tx_ring, txb, XNB_RING_TYPE_RX, and XNB_RING_TYPE_TX.
Referenced by xnb_setup_sysctl().
|
static |
Definition at line 296 of file netback.c.
References DPRINTF.
Referenced by xnb_ring2pkt().
|
static |
Free dynamically allocated KVA or pseudo-physical address allocations.
xnb | Per-instance xnb configuration structure. |
Definition at line 620 of file netback.c.
References xnb_softc::dev, xnb_softc::gnt_base_addr, xnb_softc::kva, xnb_softc::pseudo_phys_res, xnb_softc::pseudo_phys_res_id, and xenmem_free().
Referenced by xnb_disconnect().
|
static |
Handle state changes expressed via the XenStore by our front-end peer.
dev | NewBus device object representing this Xen Net Back instance. |
frontend_state | The new state of the front-end. |
Definition at line 1383 of file netback.c.
References xnb_softc::dev, DPRINTF, xnb_softc::sc_lock, xnb_connect(), and xnb_shutdown().
|
static |
Definition at line 2448 of file netback.c.
References xnb_softc::sc_lock, and xnb_ifinit_locked().
Referenced by create_netdev(), and xnb_ioctl().
|
static |
Definition at line 2429 of file netback.c.
References ifp, xnb_softc::sc_lock, xnb_softc::xnb_ifp, and xnb_stop().
Referenced by xnb_ifinit(), and xnb_ioctl().
|
static |
Callback used by the generic networking code to ask us what our carrier state is. Since we don't have a physical carrier, this is very simple
Definition at line 2472 of file netback.c.
Referenced by create_netdev().
|
static |
Callback used by the generic networking code to tell us when our carrier state has changed. Since we don't have a physical carrier, we don't care
Definition at line 2462 of file netback.c.
Referenced by create_netdev().
|
static |
Interrupt handler bound to the shared ring's event channel. Entry point for the xennet transmit path in netback Transfers packets from the Xen ring to the host's generic networking stack
arg | Callback argument registerd during event channel binding - the xnb_softc for this instance. |
Definition at line 1425 of file netback.c.
References xnb_ring_config::back_ring, ifp, notify(), xnb_softc::otherend_id, xnb_softc::ring_configs, xnb_softc::tx_gnttab, xnb_softc::tx_lock, xnb_ring_config::tx_ring, txb, xnb_softc::xen_intr_handle, xnb_softc::xnb_ifp, xnb_recv(), XNB_RING_TYPE_TX, and xnb_start().
Referenced by xnb_connect_comms().
|
static |
Definition at line 2201 of file netback.c.
References ifp, xnb_softc::sc_lock, xnb_softc::sc_media, XNB_CSUM_FEATURES, xnb_ifinit(), xnb_ifinit_locked(), and xnb_stop().
Referenced by create_netdev().
|
static |
Create an xnb_pkt based on the contents of an mbuf chain.
[in] | mbufc | mbuf chain to transform into a packet |
[out] | pkt | Storage for the newly generated xnb_pkt |
[in] | start | The ring index of the first available slot in the rx ring |
[in] | space | The number of free slots in the rx ring |
0 | Success |
EINVAL | mbufc was corrupt or not convertible into a pkt |
EAGAIN | There was not enough space in the ring to queue the packet |
Definition at line 1879 of file netback.c.
References xnb_pkt::car, xnb_pkt::car_size, xnb_pkt::cdr, xnb_pkt::extra, xnb_pkt::flags, xnb_pkt::list_len, xnb_pkt::size, xnb_pkt_invalidate(), and xnb_pkt_validate().
Referenced by xnb_mbufc2pkt_1cluster(), xnb_mbufc2pkt_2short(), xnb_mbufc2pkt_empty(), xnb_mbufc2pkt_extra(), xnb_mbufc2pkt_long(), xnb_mbufc2pkt_nospace(), xnb_mbufc2pkt_short(), xnb_rxpkt2gnttab_2req(), xnb_rxpkt2gnttab_empty(), xnb_rxpkt2gnttab_short(), xnb_rxpkt2rsp_2short(), xnb_rxpkt2rsp_2slots(), xnb_rxpkt2rsp_copyerror(), xnb_rxpkt2rsp_empty(), xnb_rxpkt2rsp_extra(), xnb_rxpkt2rsp_short(), and xnb_send().
|
static |
Create an mbuf chain to represent a packet. Initializes all of the headers in the mbuf chain, but does not copy the data. The returned chain must be free()'d when no longer needed
[in] | pkt | A packet to model the mbuf chain after |
Definition at line 1656 of file netback.c.
References xnb_pkt::flags, ifp, and xnb_pkt::size.
Referenced by xnb_pkt2mbufc_1cluster(), xnb_pkt2mbufc_2cluster(), xnb_pkt2mbufc_csum(), xnb_pkt2mbufc_empty(), xnb_pkt2mbufc_largecluster(), xnb_pkt2mbufc_short(), xnb_recv(), xnb_txpkt2gnttab_2cluster(), xnb_txpkt2gnttab_2req(), xnb_txpkt2gnttab_empty(), xnb_txpkt2gnttab_short(), xnb_update_mbufc_2cluster(), xnb_update_mbufc_2req(), and xnb_update_mbufc_short().
|
inlinestatic |
xnb_pkt method: initialize it
Definition at line 249 of file netback.c.
Referenced by xnb_ring2pkt().
|
inlinestatic |
xnb_pkt method: mark the packet as invalid
Definition at line 263 of file netback.c.
References xnb_pkt::error.
Referenced by xnb_mbufc2pkt(), and xnb_ring2pkt().
|
inlinestatic |
xnb_pkt method: Check whether the packet is valid
Definition at line 270 of file netback.c.
References xnb_pkt::error.
Referenced by xnb_mbufc2pkt_1cluster(), xnb_mbufc2pkt_2short(), xnb_mbufc2pkt_empty(), xnb_mbufc2pkt_extra(), xnb_mbufc2pkt_long(), xnb_mbufc2pkt_nospace(), xnb_mbufc2pkt_short(), xnb_recv(), xnb_ring2pkt_1req(), xnb_ring2pkt_2req(), xnb_ring2pkt_3req(), xnb_ring2pkt_extra(), xnb_ring2pkt_partial(), xnb_ring2pkt_wraps(), xnb_rxpkt2gnttab(), xnb_txpkt2rsp(), and xnb_txpkt2rsp_invalid().
|
inlinestatic |
xnb_pkt method: mark the packet as valid
Definition at line 256 of file netback.c.
References xnb_pkt::error.
Referenced by xnb_mbufc2pkt().
|
static |
|
static |
Supply information about the physical device to the frontend via XenBus.
xnb | Per-instance xnb configuration structure. |
Definition at line 940 of file netback.c.
References xnb_softc::dev, XNB_GSO_TCPV4, XNB_RX_COPY, XNB_RX_FLIP, XNB_SG, xs_printf(), xs_transaction_end(), and xs_transaction_start().
Referenced by xnb_attach().
|
static |
Dequeue at most one packet from the shared ring
[in,out] | txb | Netif tx ring. A packet will be removed from it, and its private indices will be updated. But the indices will not be pushed to the shared ring. |
[in] | ifnet | Interface to which the packet will be sent |
[in] | otherend | Domain ID of the other end of the ring |
[out] | mbufc | The assembled mbuf chain, ready to send to the generic networking stack |
[in,out] | gnttab | Pointer to enough memory for a grant table. We make this a function parameter so that we will take less stack space. |
Definition at line 1807 of file netback.c.
References DPRINTF, gnttab, txb, xnb_pkt2mbufc(), xnb_pkt_is_valid(), xnb_ring2pkt(), xnb_txpkt2gnttab(), xnb_txpkt2rsp(), and xnb_update_mbufc().
Referenced by xnb_intr().
|
static |
|
static |
Build a struct xnb_pkt based on netif_tx_request's from a netif tx ring. Will read exactly 0 or 1 packets from the ring; never a partial packet.
[out] | pkt | The returned packet. If there is an error building the packet, pkt.list_len will be set to 0. |
[in] | tx_ring | Pointer to the Ring that is the input to this function |
[in] | start | The ring index of the first potential request |
Definition at line 1477 of file netback.c.
References xnb_pkt::car, xnb_pkt::car_size, xnb_pkt::cdr, xnb_pkt::extra, xnb_pkt::flags, xnb_pkt::list_len, RING_HAS_UNCONSUMED_REQUESTS_2, xnb_pkt::size, xnb_dump_txreq(), xnb_pkt_initialize(), and xnb_pkt_invalidate().
Referenced by xnb_get1pkt(), xnb_pkt2mbufc_empty(), xnb_recv(), xnb_ring2pkt_1req(), xnb_ring2pkt_2req(), xnb_ring2pkt_3req(), xnb_ring2pkt_emptyring(), xnb_ring2pkt_extra(), xnb_ring2pkt_partial(), xnb_ring2pkt_wraps(), xnb_txpkt2gnttab_2cluster(), xnb_txpkt2gnttab_2req(), xnb_txpkt2gnttab_empty(), xnb_txpkt2gnttab_short(), xnb_txpkt2rsp_1req(), xnb_txpkt2rsp_emptypkt(), xnb_txpkt2rsp_error(), xnb_txpkt2rsp_extra(), xnb_txpkt2rsp_invalid(), xnb_txpkt2rsp_long(), xnb_txpkt2rsp_wraps(), xnb_update_mbufc_2cluster(), xnb_update_mbufc_2req(), and xnb_update_mbufc_short().
|
static |
Build a gnttab_copy table that can be used to copy data from an mbuf chain to the frontend's shared buffers. Does not actually perform the copy. Always uses gref's on the other end's side.
[in] | pkt | pkt's associated responses form the dest for the copy operatoin |
[in] | mbufc | The source for the copy operation |
[out] | gnttab | Storage for the returned grant table |
[in] | rxb | Pointer to the backend ring structure |
[in] | otherend_id | The domain ID of the other end of the copy |
Definition at line 1952 of file netback.c.
References xnb_pkt::car, xnb_pkt::cdr, gnttab, GNTTAB_LEN, rxb, xnb_pkt::size, virt_to_mfn, virt_to_offset, and xnb_pkt_is_valid().
Referenced by xnb_rxpkt2gnttab_2req(), xnb_rxpkt2gnttab_empty(), xnb_rxpkt2gnttab_short(), xnb_rxpkt2rsp_2short(), xnb_rxpkt2rsp_2slots(), xnb_rxpkt2rsp_copyerror(), xnb_rxpkt2rsp_empty(), xnb_rxpkt2rsp_extra(), xnb_rxpkt2rsp_short(), and xnb_send().
|
static |
Generates responses for all the requests that constituted pkt. Builds responses and writes them to the ring, but doesn't push the shared ring indices.
[in] | pkt | the packet that needs a response |
[in] | gnttab | The grant copy table corresponding to this packet. Used to determine how many rsp->netif_rx_response_t's to generate. |
[in] | n_entries | Number of relevant entries in the grant table |
[out] | ring | Responses go here |
Definition at line 2027 of file netback.c.
References DPRINTF, xnb_pkt::extra, xnb_pkt::flags, and gnttab.
Referenced by xnb_rxpkt2rsp_2short(), xnb_rxpkt2rsp_2slots(), xnb_rxpkt2rsp_copyerror(), xnb_rxpkt2rsp_empty(), xnb_rxpkt2rsp_extra(), xnb_rxpkt2rsp_short(), and xnb_send().
|
static |
Sends one packet to the ring. Blocks until the packet is on the ring
[in] | mbufc | Contains one packet to send. Caller must free |
[in,out] | rxb | The packet will be pushed onto this ring, but the otherend will not be notified. |
[in] | otherend | The domain ID of the other end of the connection |
EAGAIN | The ring did not have enough space for the packet. The ring has not been modified |
[in,out] | gnttab | Pointer to enough memory for a grant table. We make this a function parameter so that we will take less stack space. |
EINVAL | mbufc was corrupt or not convertible into a pkt |
Definition at line 2392 of file netback.c.
References xnb_pkt::error, gnttab, xnb_mbufc2pkt(), xnb_rxpkt2gnttab(), and xnb_rxpkt2rsp().
Referenced by xnb_start_locked().
|
static |
Setup sysctl variables to control various Network Back parameters.
xnb | Xen Net Back softc. |
Definition at line 1138 of file netback.c.
References xnb_softc::dev, xnb_dump_rings(), and xnb_unit_test_main().
Referenced by xnb_attach().
|
static |
Perform device shutdown functions.
xnb | Per-instance xnb configuration structure. |
Mark this instance as shutting down, wait for any active requests to drain, disconnect from the front-end, and notify any waiters (e.g. a thread invoking our detach method) that detach can now proceed.
Definition at line 1042 of file netback.c.
References xnb_softc::carrier, xnb_softc::dev, xnb_softc::flags, xnb_softc::sc_lock, xnb_disconnect(), xnb_softc::xnb_ifp, XNBF_IN_SHUTDOWN, and XNBF_SHUTDOWN.
Referenced by xnb_detach(), and xnb_frontend_changed().
|
static |
Definition at line 2417 of file netback.c.
References ifp, xnb_softc::rx_lock, and xnb_start_locked().
Referenced by create_netdev(), and xnb_intr().
|
static |
Definition at line 2312 of file netback.c.
References xnb_ring_config::back_ring, xnb_softc::carrier, ifp, notify(), xnb_softc::otherend_id, xnb_softc::ring_configs, xnb_softc::rx_gnttab, xnb_ring_config::rx_ring, rxb, xnb_softc::xen_intr_handle, XNB_RING_TYPE_RX, and xnb_send().
Referenced by xnb_start().
|
static |
Definition at line 2190 of file netback.c.
References ifp, xnb_softc::sc_lock, and xnb_softc::xnb_ifp.
Referenced by xnb_ifinit_locked(), and xnb_ioctl().
|
static |
|
static |
Build a gnttab_copy table that can be used to copy data from a pkt to an mbufc. Does not actually perform the copy. Always uses gref's on the packet side.
[in] | pkt | pkt's associated requests form the src for the copy operation |
[in] | mbufc | mbufc's storage forms the dest for the copy operation |
[out] | gnttab | Storage for the returned grant table |
[in] | txb | Pointer to the backend ring structure |
[in] | otherend_id | The domain ID of the other end of the copy |
Definition at line 1700 of file netback.c.
References xnb_pkt::car, xnb_pkt::car_size, xnb_pkt::cdr, gnttab, GNTTAB_LEN, xnb_pkt::size, txb, virt_to_mfn, and virt_to_offset.
Referenced by xnb_recv(), xnb_txpkt2gnttab_2cluster(), xnb_txpkt2gnttab_2req(), xnb_txpkt2gnttab_empty(), xnb_txpkt2gnttab_short(), xnb_update_mbufc_2cluster(), xnb_update_mbufc_2req(), and xnb_update_mbufc_short().
|
static |
Respond to all the requests that constituted pkt. Builds the responses and writes them to the ring, but doesn't push them to the shared ring.
[in] | pkt | the packet that needs a response |
[in] | error | true if there was an error handling the packet, such as in the hypervisor copy op or mbuf allocation |
[out] | ring | Responses go here |
Definition at line 1599 of file netback.c.
References xnb_pkt::car, xnb_pkt::flags, xnb_pkt::list_len, and xnb_pkt_is_valid().
Referenced by xnb_recv(), xnb_txpkt2rsp_1req(), xnb_txpkt2rsp_emptypkt(), xnb_txpkt2rsp_error(), xnb_txpkt2rsp_extra(), xnb_txpkt2rsp_invalid(), xnb_txpkt2rsp_long(), and xnb_txpkt2rsp_wraps().
|
static |
|
static |
Check the status of the grant copy operations, and update mbufs various non-data fields to reflect the data present.
[in,out] | mbufc | mbuf chain to update. The chain must be valid and of the correct length, and data should already be present |
[in] | gnttab | A grant table for a just completed copy op |
[in] | n_entries | The number of valid entries in the grant table |
Definition at line 1767 of file netback.c.
References gnttab.
Referenced by xnb_recv(), xnb_update_mbufc_2cluster(), xnb_update_mbufc_2req(), and xnb_update_mbufc_short().
|
static |
|
static |