diff options
| author | Vincenzo Maffione <vmaffione@FreeBSD.org> | 2018-04-04 21:31:12 +0000 |
|---|---|---|
| committer | Vincenzo Maffione <vmaffione@FreeBSD.org> | 2018-04-04 21:31:12 +0000 |
| commit | 46023447b69f76174fb12abd910b9b6cba31345b (patch) | |
| tree | 700f09ec117a37174173ded14796c503cc30a0ea /sys/net/netmap_virt.h | |
| parent | cdfebb9cf592ed575d90a0569e7929f77940112e (diff) | |
Notes
Diffstat (limited to 'sys/net/netmap_virt.h')
| -rw-r--r-- | sys/net/netmap_virt.h | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/sys/net/netmap_virt.h b/sys/net/netmap_virt.h index e5c823ea2f28..a520a16dc9b1 100644 --- a/sys/net/netmap_virt.h +++ b/sys/net/netmap_virt.h @@ -85,7 +85,8 @@ struct ptnetmap_cfg { uint16_t cfgtype; /* how to interpret the cfg entries */ uint16_t entry_size; /* size of a config entry */ uint32_t num_rings; /* number of config entries */ - void *ptrings; /* ptrings inside CSB */ + void *csb_gh; /* CSB for guest --> host communication */ + void *csb_hg; /* CSB for host --> guest communication */ /* Configuration entries are allocated right after the struct. */ }; @@ -146,8 +147,8 @@ nmreq_pointer_put(struct nmreq *nmr, void *userptr) #define PTNET_IO_PTCTL 4 #define PTNET_IO_MAC_LO 8 #define PTNET_IO_MAC_HI 12 -#define PTNET_IO_CSBBAH 16 -#define PTNET_IO_CSBBAL 20 +#define PTNET_IO_CSBBAH 16 /* deprecated */ +#define PTNET_IO_CSBBAL 20 /* deprecated */ #define PTNET_IO_NIFP_OFS 24 #define PTNET_IO_NUM_TX_RINGS 28 #define PTNET_IO_NUM_RX_RINGS 32 @@ -155,7 +156,11 @@ nmreq_pointer_put(struct nmreq *nmr, void *userptr) #define PTNET_IO_NUM_RX_SLOTS 40 #define PTNET_IO_VNET_HDR_LEN 44 #define PTNET_IO_HOSTMEMID 48 -#define PTNET_IO_END 52 +#define PTNET_IO_CSB_GH_BAH 52 +#define PTNET_IO_CSB_GH_BAL 56 +#define PTNET_IO_CSB_HG_BAH 60 +#define PTNET_IO_CSB_HG_BAL 64 +#define PTNET_IO_END 68 #define PTNET_IO_KICK_BASE 128 #define PTNET_IO_MASK 0xff @@ -163,26 +168,19 @@ nmreq_pointer_put(struct nmreq *nmr, void *userptr) #define PTNETMAP_PTCTL_CREATE 1 #define PTNETMAP_PTCTL_DELETE 2 -/* If defined, CSB is allocated by the guest, not by the host. */ -#define PTNET_CSB_ALLOC - -/* ptnetmap ring fields shared between guest and host */ -struct ptnet_ring { - /* XXX revise the layout to minimize cache bounces. */ +/* ptnetmap synchronization variables shared between guest and host */ +struct ptnet_csb_gh { uint32_t head; /* GW+ HR+ the head of the guest netmap_ring */ uint32_t cur; /* GW+ HR+ the cur of the guest netmap_ring */ uint32_t guest_need_kick; /* GW+ HR+ host-->guest notification enable */ uint32_t sync_flags; /* GW+ HR+ the flags of the guest [tx|rx]sync() */ + char pad[48]; /* pad to a 64 bytes cacheline */ +}; +struct ptnet_csb_hg { uint32_t hwcur; /* GR+ HW+ the hwcur of the host netmap_kring */ uint32_t hwtail; /* GR+ HW+ the hwtail of the host netmap_kring */ uint32_t host_need_kick; /* GR+ HW+ guest-->host notification enable */ - char pad[4]; -}; - -/* CSB for the ptnet device. */ -struct ptnet_csb { -#define NETMAP_VIRT_CSB_SIZE 4096 - struct ptnet_ring rings[NETMAP_VIRT_CSB_SIZE/sizeof(struct ptnet_ring)]; + char pad[4+48]; }; #ifdef WITH_PTNETMAP_GUEST @@ -197,7 +195,7 @@ uint32_t nm_os_pt_memdev_ioread(struct ptnetmap_memdev *, unsigned int); /* Guest driver: Write kring pointers (cur, head) to the CSB. * This routine is coupled with ptnetmap_host_read_kring_csb(). */ static inline void -ptnetmap_guest_write_kring_csb(struct ptnet_ring *ptr, uint32_t cur, +ptnetmap_guest_write_kring_csb(struct ptnet_csb_gh *ptr, uint32_t cur, uint32_t head) { /* @@ -228,16 +226,16 @@ ptnetmap_guest_write_kring_csb(struct ptnet_ring *ptr, uint32_t cur, /* Guest driver: Read kring pointers (hwcur, hwtail) from the CSB. * This routine is coupled with ptnetmap_host_write_kring_csb(). */ static inline void -ptnetmap_guest_read_kring_csb(struct ptnet_ring *ptr, struct netmap_kring *kring) +ptnetmap_guest_read_kring_csb(struct ptnet_csb_hg *pthg, struct netmap_kring *kring) { /* * We place a memory barrier to make sure that the update of hwtail never * overtakes the update of hwcur. * (see explanation in ptnetmap_host_write_kring_csb). */ - kring->nr_hwtail = ptr->hwtail; + kring->nr_hwtail = pthg->hwtail; mb(); - kring->nr_hwcur = ptr->hwcur; + kring->nr_hwcur = pthg->hwcur; } #endif /* WITH_PTNETMAP_GUEST */ @@ -259,7 +257,7 @@ ptnetmap_guest_read_kring_csb(struct ptnet_ring *ptr, struct netmap_kring *kring /* Host netmap: Write kring pointers (hwcur, hwtail) to the CSB. * This routine is coupled with ptnetmap_guest_read_kring_csb(). */ static inline void -ptnetmap_host_write_kring_csb(struct ptnet_ring __user *ptr, uint32_t hwcur, +ptnetmap_host_write_kring_csb(struct ptnet_csb_hg __user *ptr, uint32_t hwcur, uint32_t hwtail) { /* @@ -285,7 +283,7 @@ ptnetmap_host_write_kring_csb(struct ptnet_ring __user *ptr, uint32_t hwcur, /* Host netmap: Read kring pointers (head, cur, sync_flags) from the CSB. * This routine is coupled with ptnetmap_guest_write_kring_csb(). */ static inline void -ptnetmap_host_read_kring_csb(struct ptnet_ring __user *ptr, +ptnetmap_host_read_kring_csb(struct ptnet_csb_gh __user *ptr, struct netmap_ring *shadow_ring, uint32_t num_slots) { |
