1/** 2 * \file 3 * \brief Proxy for connecting bulk transfer channels over a network connection 4 */ 5 6/* 7 * Copyright (c) 2014, 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_PROXY_H 16#define BULK_NET_PROXY_H 17 18#include <barrelfish/barrelfish.h> 19#include <bulk_transfer/bulk_transfer.h> 20#include <bulk_transfer/bulk_net.h> 21 22#include <dev/e10k_dev.h> 23 24 25/* Internal stuff, only here to avoid unnecessary mallocs */ 26struct transmit_buffer; 27struct receive_buffer; 28 29 30/** Proxy handle struct */ 31struct bulk_net_proxy { 32 struct waitset *ws; 33 struct bulk_channel channel; 34 size_t buffer_size; 35 36 errval_t err; 37 bool bulk_bound; 38 bool net_bound; 39 void (*connected)(struct bulk_net_proxy *); 40 41 struct bulk_e10k transfer; 42 43 struct stack_allocator rb_stack; 44 struct transmit_buffer *tb; 45 struct stack_allocator tb_stack; 46 47 struct bulk_continuation panic_cont; 48 void *zero_meta; 49 50 // Coordinates for network connection 51 const char *card; 52 uint8_t queue; 53 uint16_t l_port; 54 uint16_t r_port; 55 uint32_t l_ip; 56 uint32_t r_ip; 57 uint64_t l_mac; 58 uint64_t r_mac; 59 60 void *user_state; 61}; 62 63/** 64 * Start listening proxy on the specified port. Note that the proxy will bind to 65 * the bulk channel during the initialization phase, before actually receiving a 66 * connection request. But transfers on the channel (including the passing of 67 * buffers for the receive queue) must only be executed after the connected 68 * callback is called. 69 * 70 * @param p Proxy struct 71 * @param desc Bulk endpoint to bind to 72 * @param ws Waitset 73 * @param buffer_size Size of buffers to be transmitted over this proxy 74 * @param card NIC name in barrelfish 75 * @param queue Queue ID to use 76 * @param port Port number to listen on (host byte order) 77 * @param connected Callback, will be invoked once an incoming connection has 78 * been established. 79 */ 80errval_t bulk_net_proxy_listen(struct bulk_net_proxy *p, 81 struct bulk_endpoint_descriptor *desc, 82 struct waitset *ws, 83 size_t buffer_size, 84 const char *card, 85 uint8_t queue, 86 uint16_t port, 87 void (*connected)(struct bulk_net_proxy *)); 88 89/** 90 * Connect to listening proxy. Note that the proxy will bind to the bulk channel 91 * during the initialization phase, before actually receiving a connection 92 * request. But transfers on the channel (including the passing of buffers for 93 * the receive queue) must only be executed after the connected callback is 94 * called. 95 * @param p Proxy struct 96 * @param desc Bulk endpoint to bind to 97 * @param ws Waitset 98 * @param buffer_size Size of buffers to be transmitted over this proxy 99 * @param card NIC name in barrelfish 100 * @param queue Queue ID to use 101 * @param ip IP to connect to (host byte order) 102 * @param port Port number to connect to (host byte order) 103 * @param connected Callback, will be invoked once the connection has 104 * been established. 105* 106 */ 107errval_t bulk_net_proxy_connect(struct bulk_net_proxy *p, 108 struct bulk_endpoint_descriptor *desc, 109 struct waitset *ws, 110 size_t buffer_size, 111 const char *card, 112 uint8_t queue, 113 uint32_t ip, 114 uint16_t port, 115 void (*connected)(struct bulk_net_proxy *)); 116 117#endif /* BULK_NET_H */ 118