1/** 2 * \file 3 * \brief Unidirectional bulk data transfer via shared memory 4 */ 5 6/* 7 * Copyright (c) 2009, 2010, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#ifndef BULK_NET_H 16#define BULK_NET_H 17 18#include <bulk_transfer/bulk_transfer.h> 19#include <barrelfish/event_queue.h> 20 21#include <netinet/in.h> 22 23#include <dev/e10k_dev.h> 24#include <lwip/ip_addr.h> 25 26struct bulk_net_msgdesc; 27struct e10k_binding; 28struct e10k_queue; 29 30struct stack_allocator { 31 size_t size; 32 size_t top; 33 void **stack; 34}; 35 36struct bulk_e10k { 37 bool ready; 38 size_t buffer_size; 39 size_t ring_size; 40 uint8_t qi; 41 uint8_t int_core; 42 uint8_t int_vector; 43 struct e10k_binding *binding; 44 e10k_t d; 45 struct e10k_queue *q; 46 uint64_t mac; 47 struct capref rxframe; 48 struct capref txframe; 49 struct capref txhwbframe; 50 void (*received)(struct bulk_e10k *, 51 struct bulk_net_msgdesc *); 52 void (*transmitted)(struct bulk_e10k *, 53 void *); 54 55 struct event_queue event_queue; 56 struct stack_allocator rx_event_alloc; 57 struct stack_allocator tx_event_alloc; 58 59 struct waitset *waitset; 60 struct waitset_chanstate wscs; 61 62 void *opaque; 63}; 64 65 66 67/** 68 * endpoint descriptor for the bulk network interface. 69 * 70 * XXX: the queue identifiers are for the control channel. 71 * we may have to distinguish the different pools with different queues 72 * because the buffer sizes may vary among pools. 73 * - RA 74 */ 75struct bulk_net_endpoint_descriptor { 76 /* generic part */ 77 struct bulk_endpoint_descriptor ep_generic; ///< generic endpoint part 78 /* start of implementation specific part */ 79 struct ip_addr ip; ///< ip address 80 uint16_t port; ///< port 81 /* from transparent endpoint */ 82 char *cardname; 83 uint8_t queue; 84 uint8_t max_queues; 85 size_t buffer_size; 86 size_t buffer_count; 87 /* 88 * XXX: do we want to add the connection information here as well? 89 * e.g. tcp_pcb ? 90 */ 91}; 92 93/** 94 * setup parameters for creating a network endpoint 95 */ 96struct bulk_net_ep_setup { 97 struct ip_addr ip; ///< the ip address of the endpoint 98 uint16_t port; ///< the port of the endpoint 99 /* possibly queue id */ 100 uint8_t queue; 101 uint8_t max_queues; 102 size_t buffer_size; 103 size_t buffer_count; 104 char *cardname; 105 bool no_copy; 106}; 107 108 109/** 110 * Creates a new bulk endpoint which uses the network backend 111 * 112 * @param ep_desc memory location to create the endpoint in 113 * @param setup the setup parameters for the endpoint 114 * 115 * This function is intended to be used by the creator. 116 */ 117errval_t bulk_net_ep_create(struct bulk_net_endpoint_descriptor *ep_desc, 118 struct bulk_net_ep_setup *setup); 119 120/** 121 * Destroys the given endpoint 122 * 123 * @param ep_desc the endpoint to be destroyed 124 */ 125errval_t bulk_net_ep_destroy(struct bulk_net_endpoint_descriptor *ep_desc); 126 127/** 128 * Explicitly creates a specific remote endpoint 129 * 130 * @param ep_desc memory location to create the endpoint 131 * @param ip the ip of the server machine 132 * @param port the port where the otherside listens to 133 */ 134errval_t bulk_net_ep_create_remote(struct bulk_net_endpoint_descriptor *ep_desc, 135 struct bulk_net_ep_setup *setup); 136#endif /* BULK_NET_H */ 137