Deleted Added
full compact
netback.c (279394) netback.c (282274)
1/*-
2 * Copyright (c) 2009-2011 Spectra Logic Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * POSSIBILITY OF SUCH DAMAGES.
29 *
30 * Authors: Justin T. Gibbs (Spectra Logic Corporation)
31 * Alan Somers (Spectra Logic Corporation)
32 * John Suykerbuyk (Spectra Logic Corporation)
33 */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2011 Spectra Logic Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 19 unchanged lines hidden (view full) ---

28 * POSSIBILITY OF SUCH DAMAGES.
29 *
30 * Authors: Justin T. Gibbs (Spectra Logic Corporation)
31 * Alan Somers (Spectra Logic Corporation)
32 * John Suykerbuyk (Spectra Logic Corporation)
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/dev/xen/netback/netback.c 279394 2015-02-28 15:21:06Z royger $");
36__FBSDID("$FreeBSD: head/sys/dev/xen/netback/netback.c 282274 2015-04-30 15:48:48Z jhb $");
37
38/**
39 * \file netback.c
40 *
41 * \brief Device driver supporting the vending of network access
42 * from this FreeBSD domain to other domains.
43 */
44#include "opt_inet.h"

--- 423 unchanged lines hidden (view full) ---

468 gnttab_copy_table rx_gnttab;
469
470 /**
471 * Preallocated grant table copy descriptor for TX operations.
472 * Access must be protected by tx_lock
473 */
474 gnttab_copy_table tx_gnttab;
475
37
38/**
39 * \file netback.c
40 *
41 * \brief Device driver supporting the vending of network access
42 * from this FreeBSD domain to other domains.
43 */
44#include "opt_inet.h"

--- 423 unchanged lines hidden (view full) ---

468 gnttab_copy_table rx_gnttab;
469
470 /**
471 * Preallocated grant table copy descriptor for TX operations.
472 * Access must be protected by tx_lock
473 */
474 gnttab_copy_table tx_gnttab;
475
476#ifdef XENHVM
477 /**
478 * Resource representing allocated physical address space
479 * associated with our per-instance kva region.
480 */
481 struct resource *pseudo_phys_res;
482
483 /** Resource id for allocated physical address space. */
484 int pseudo_phys_res_id;
476 /**
477 * Resource representing allocated physical address space
478 * associated with our per-instance kva region.
479 */
480 struct resource *pseudo_phys_res;
481
482 /** Resource id for allocated physical address space. */
483 int pseudo_phys_res_id;
485#endif
486
487 /** Ring mapping and interrupt configuration data. */
488 struct xnb_ring_config ring_configs[XNB_NUM_RING_TYPES];
489
490 /**
491 * Global pool of kva used for mapping remote domain ring
492 * and I/O transaction data.
493 */

--- 127 unchanged lines hidden (view full) ---

621 * Free dynamically allocated KVA or pseudo-physical address allocations.
622 *
623 * \param xnb Per-instance xnb configuration structure.
624 */
625static void
626xnb_free_communication_mem(struct xnb_softc *xnb)
627{
628 if (xnb->kva != 0) {
484
485 /** Ring mapping and interrupt configuration data. */
486 struct xnb_ring_config ring_configs[XNB_NUM_RING_TYPES];
487
488 /**
489 * Global pool of kva used for mapping remote domain ring
490 * and I/O transaction data.
491 */

--- 127 unchanged lines hidden (view full) ---

619 * Free dynamically allocated KVA or pseudo-physical address allocations.
620 *
621 * \param xnb Per-instance xnb configuration structure.
622 */
623static void
624xnb_free_communication_mem(struct xnb_softc *xnb)
625{
626 if (xnb->kva != 0) {
629#ifndef XENHVM
630 kva_free(xnb->kva, xnb->kva_size);
631#else
632 if (xnb->pseudo_phys_res != NULL) {
633 bus_release_resource(xnb->dev, SYS_RES_MEMORY,
634 xnb->pseudo_phys_res_id,
635 xnb->pseudo_phys_res);
636 xnb->pseudo_phys_res = NULL;
637 }
627 if (xnb->pseudo_phys_res != NULL) {
628 bus_release_resource(xnb->dev, SYS_RES_MEMORY,
629 xnb->pseudo_phys_res_id,
630 xnb->pseudo_phys_res);
631 xnb->pseudo_phys_res = NULL;
632 }
638#endif /* XENHVM */
639 }
640 xnb->kva = 0;
641 xnb->gnt_base_addr = 0;
642}
643
644/**
645 * Cleanup all inter-domain communication mechanisms.
646 *

--- 164 unchanged lines hidden (view full) ---

811xnb_alloc_communication_mem(struct xnb_softc *xnb)
812{
813 xnb_ring_type_t i;
814
815 xnb->kva_size = 0;
816 for (i=0; i < XNB_NUM_RING_TYPES; i++) {
817 xnb->kva_size += xnb->ring_configs[i].ring_pages * PAGE_SIZE;
818 }
633 }
634 xnb->kva = 0;
635 xnb->gnt_base_addr = 0;
636}
637
638/**
639 * Cleanup all inter-domain communication mechanisms.
640 *

--- 164 unchanged lines hidden (view full) ---

805xnb_alloc_communication_mem(struct xnb_softc *xnb)
806{
807 xnb_ring_type_t i;
808
809 xnb->kva_size = 0;
810 for (i=0; i < XNB_NUM_RING_TYPES; i++) {
811 xnb->kva_size += xnb->ring_configs[i].ring_pages * PAGE_SIZE;
812 }
819#ifndef XENHVM
820 xnb->kva = kva_alloc(xnb->kva_size);
821 if (xnb->kva == 0)
822 return (ENOMEM);
823 xnb->gnt_base_addr = xnb->kva;
824#else /* defined XENHVM */
813
825 /*
826 * Reserve a range of pseudo physical memory that we can map
827 * into kva. These pages will only be backed by machine
828 * pages ("real memory") during the lifetime of front-end requests
829 * via grant table operations. We will map the netif tx and rx rings
830 * into this space.
831 */
832 xnb->pseudo_phys_res_id = 0;
833 xnb->pseudo_phys_res = bus_alloc_resource(xnb->dev, SYS_RES_MEMORY,
834 &xnb->pseudo_phys_res_id,
835 0, ~0, xnb->kva_size,
836 RF_ACTIVE);
837 if (xnb->pseudo_phys_res == NULL) {
838 xnb->kva = 0;
839 return (ENOMEM);
840 }
841 xnb->kva = (vm_offset_t)rman_get_virtual(xnb->pseudo_phys_res);
842 xnb->gnt_base_addr = rman_get_start(xnb->pseudo_phys_res);
814 /*
815 * Reserve a range of pseudo physical memory that we can map
816 * into kva. These pages will only be backed by machine
817 * pages ("real memory") during the lifetime of front-end requests
818 * via grant table operations. We will map the netif tx and rx rings
819 * into this space.
820 */
821 xnb->pseudo_phys_res_id = 0;
822 xnb->pseudo_phys_res = bus_alloc_resource(xnb->dev, SYS_RES_MEMORY,
823 &xnb->pseudo_phys_res_id,
824 0, ~0, xnb->kva_size,
825 RF_ACTIVE);
826 if (xnb->pseudo_phys_res == NULL) {
827 xnb->kva = 0;
828 return (ENOMEM);
829 }
830 xnb->kva = (vm_offset_t)rman_get_virtual(xnb->pseudo_phys_res);
831 xnb->gnt_base_addr = rman_get_start(xnb->pseudo_phys_res);
843#endif /* !defined XENHVM */
844 return (0);
845}
846
847/**
848 * Collect information from the XenStore related to our device and its frontend
849 *
850 * \param xnb Per-instance xnb configuration structure.
851 */

--- 1684 unchanged lines hidden ---
832 return (0);
833}
834
835/**
836 * Collect information from the XenStore related to our device and its frontend
837 *
838 * \param xnb Per-instance xnb configuration structure.
839 */

--- 1684 unchanged lines hidden ---