hv_rndis_filter.h revision 251775
1/*- 2 * Copyright (c) 2009-2012 Microsoft Corp. 3 * Copyright (c) 2010-2012 Citrix Inc. 4 * Copyright (c) 2012 NetApp Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#ifndef __HV_RNDIS_FILTER_H__ 30#define __HV_RNDIS_FILTER_H__ 31 32 33/* 34 * Defines 35 */ 36 37/* Destroy or preserve channel on filter/netvsc teardown */ 38#define HV_RF_NV_DESTROY_CHANNEL TRUE 39#define HV_RF_NV_RETAIN_CHANNEL FALSE 40 41/* 42 * Number of page buffers to reserve for the RNDIS filter packet in the 43 * transmitted message. 44 */ 45#define HV_RF_NUM_TX_RESERVED_PAGE_BUFS 1 46 47 48/* 49 * Data types 50 */ 51 52typedef enum { 53 RNDIS_DEV_UNINITIALIZED = 0, 54 RNDIS_DEV_INITIALIZING, 55 RNDIS_DEV_INITIALIZED, 56 RNDIS_DEV_DATAINITIALIZED, 57} rndis_device_state; 58 59typedef struct rndis_request_ { 60 STAILQ_ENTRY(rndis_request_) mylist_entry; 61 struct sema wait_sema; 62 63 /* 64 * Fixme: We assumed a fixed size response here. If we do ever 65 * need to handle a bigger response, we can either define a max 66 * response message or add a response buffer variable above this field 67 */ 68 rndis_msg response_msg; 69 70 /* Simplify allocation by having a netvsc packet inline */ 71 netvsc_packet pkt; 72 hv_vmbus_page_buffer buffer; 73 /* Fixme: We assumed a fixed size request here. */ 74 rndis_msg request_msg; 75 /* Fixme: Poor man's semaphore. */ 76 uint32_t halt_complete_flag; 77} rndis_request; 78 79typedef struct rndis_device_ { 80 netvsc_dev *net_dev; 81 82 rndis_device_state state; 83 uint32_t link_status; 84 uint32_t new_request_id; 85 86 struct mtx req_lock; 87 88 STAILQ_HEAD(RQ, rndis_request_) myrequest_list; 89 90 uint8_t hw_mac_addr[HW_MACADDR_LEN]; 91} rndis_device; 92 93typedef struct rndis_filter_packet_ { 94 void *completion_context; 95 /* No longer used */ 96 pfn_on_send_rx_completion on_completion; 97 98 rndis_msg message; 99} rndis_filter_packet; 100 101 102/* 103 * Externs 104 */ 105 106extern int hv_rf_on_receive(struct hv_device *device, netvsc_packet *pkt); 107extern int hv_rf_on_device_add(struct hv_device *device, void *additl_info); 108extern int hv_rf_on_device_remove(struct hv_device *device, 109 boolean_t destroy_channel); 110extern int hv_rf_on_open(struct hv_device *device); 111extern int hv_rf_on_close(struct hv_device *device); 112extern int hv_rf_on_send(struct hv_device *device, netvsc_packet *pkt); 113 114 115#endif /* __HV_RNDIS_FILTER_H__ */ 116 117