1/* 2 * Copyright (c) 2007-12 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef PORT_MNG_SUPPORT_H_ 11#define PORT_MNG_SUPPORT_H_ 12 13#include <barrelfish/barrelfish.h> 14#include <if/net_ports_defs.h> 15 16typedef net_ports_port_type_t port_type_t; 17typedef net_ports_appid_t appid_t; 18typedef net_ports_qid_t qid_t; 19typedef net_ports_bufid_t bufid_t; 20 21// ***************************************************************** 22// * function pointer types for filter management (HW/SW filters) 23// ***************************************************************** 24typedef void (*init_filters_service_t)(char *dev_name, qid_t qid); 25typedef void (*register_arp_filter_t)(uint64_t id, uint64_t len_rx, 26 uint64_t len_tx); 27typedef errval_t (*register_filter_t)(uint16_t port, 28 port_type_t type, 29 bufid_t buffer_id_rx, 30 bufid_t buffer_id_tx, 31 appid_t appid, 32 qid_t qid, 33 uint64_t *id, errval_t *rerr, uint64_t *filter_id); 34typedef errval_t (*deregister_filter_t)(uint64_t filter_id, qid_t qid); 35 36 37// Struct to capture the signature of different filter managers 38struct filters_tx_vtbl { 39 char *type; 40 init_filters_service_t init_filters; 41 register_arp_filter_t reg_arp_filters; 42 register_filter_t reg_filters; 43 deregister_filter_t unreg_filters; 44}; 45 46// ***************************************************************** 47// * prototypes 48// ***************************************************************** 49 50// Get the signature for software filter manager 51struct filters_tx_vtbl *get_soft_filt_mng_sign(void); 52 53// Get the signature for e10k hardware filter manager 54struct filters_tx_vtbl *get_e10k_filt_mng_sign(void); 55 56// Get the signature for sfn5122f hardware filter manager 57struct filters_tx_vtbl *get_sfn5122f_filt_mng_sign(void); 58 59// Initialize the port number management service 60int init_ports_service(char *dev_name); 61 62// based on the response received from queue_manager, 63// report the success/failure of the call to an application 64//void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id, 65// uint64_t buffer_id_rx, uint64_t buffer_id_tx, uint64_t ftype); 66 67 68// ***************************************************************** 69// * queue list data-structures 70// ***************************************************************** 71 72// queue closure 73struct NIC_q_closure { 74 qid_t qid; // queue_id 75 struct filters_tx_vtbl *filt_mng; // filter management functionality 76}; 77 78struct NIC_q_closure *qlist; // list of all queues 79qid_t total_queues; // Total no. of valid queues (0, ..., total_queues-1) 80 81 82 83// ***************************************************************** 84// * application closure/state related 85// ***************************************************************** 86 87// The queue abstraction 88// One application can hold one or more queues 89// A queue has 90// a list of assosited buffers 91// ports/flows mapped to queue 92// list of functions to register filters 93 94 95 96 97/** 98 * This is the structure used to hold all of the ports allocated to a 99 * networking application and their relavanet buffer. This also keeps the 100 * state of the filter registration/deregistration sequence. 101 */ 102struct buffer_port_translation { 103 uint64_t buffer_id_rx; 104 uint64_t buffer_id_tx; 105 uint64_t filter_id; 106 uint64_t type; 107 uint16_t local_port; 108 uint32_t local_ip; 109 uint16_t remote_port; 110 uint32_t remote_ip; 111 bool redirected; 112 bool active; 113 bool bind; 114 bool closing; 115 bool paused; 116 struct net_ports_binding *st; 117 struct buffer_port_translation *next; 118}; 119 120 121/** 122 * Represents a network user application. This can easily be extended later. 123 */ 124struct net_user { 125 struct cont_queue *q; 126 struct net_user *next; 127 struct buffer_port_translation *open_ports; 128 bool died; 129 130 // Information about queue 131 qid_t qid; 132 133}; 134 135/* FIXME: check if you can remove any of following global variables. */ 136/** 137 * Networking daemon state 138 */ 139struct net_user *registerd_app_list; 140 141/* 142 * The IP assigned to this netd and its card interface 143 */ 144//extern struct ip_addr local_ip; 145 146 147#endif // PORT_MNG_SUPPORT_H_ 148