hv_rndis_filter.h revision 298446
1/*- 2 * Copyright (c) 2009-2012,2016 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 * $FreeBSD: head/sys/dev/hyperv/netvsc/hv_rndis_filter.h 298446 2016-04-22 05:01:43Z sephe $ 29 */ 30 31#ifndef __HV_RNDIS_FILTER_H__ 32#define __HV_RNDIS_FILTER_H__ 33 34 35/* 36 * Defines 37 */ 38 39/* Destroy or preserve channel on filter/netvsc teardown */ 40#define HV_RF_NV_DESTROY_CHANNEL TRUE 41#define HV_RF_NV_RETAIN_CHANNEL FALSE 42 43/* 44 * Number of page buffers to reserve for the RNDIS filter packet in the 45 * transmitted message. 46 */ 47#define HV_RF_NUM_TX_RESERVED_PAGE_BUFS 1 48 49 50/* 51 * Data types 52 */ 53 54typedef enum { 55 RNDIS_DEV_UNINITIALIZED = 0, 56 RNDIS_DEV_INITIALIZING, 57 RNDIS_DEV_INITIALIZED, 58 RNDIS_DEV_DATAINITIALIZED, 59} rndis_device_state; 60 61typedef struct rndis_request_ { 62 STAILQ_ENTRY(rndis_request_) mylist_entry; 63 struct sema wait_sema; 64 65 /* 66 * The max response size is sizeof(rndis_msg) + PAGE_SIZE. 67 * 68 * XXX 69 * This is ugly and should be cleaned up once we busdma-fy 70 * RNDIS request bits. 71 */ 72 rndis_msg response_msg; 73 uint8_t buf_resp[PAGE_SIZE]; 74 75 /* Simplify allocation by having a netvsc packet inline */ 76 netvsc_packet pkt; 77 hv_vmbus_page_buffer buffer; 78 79 /* 80 * The max request size is sizeof(rndis_msg) + PAGE_SIZE. 81 * 82 * NOTE: 83 * This is required for the large request like RSS settings. 84 * 85 * XXX 86 * This is ugly and should be cleaned up once we busdma-fy 87 * RNDIS request bits. 88 */ 89 rndis_msg request_msg; 90 uint8_t buf_req[PAGE_SIZE]; 91 92 /* Fixme: Poor man's semaphore. */ 93 uint32_t halt_complete_flag; 94} rndis_request; 95 96typedef struct rndis_device_ { 97 netvsc_dev *net_dev; 98 99 rndis_device_state state; 100 uint32_t link_status; 101 uint32_t new_request_id; 102 103 struct mtx req_lock; 104 105 STAILQ_HEAD(RQ, rndis_request_) myrequest_list; 106 107 uint8_t hw_mac_addr[HW_MACADDR_LEN]; 108} rndis_device; 109 110/* 111 * Externs 112 */ 113struct hv_vmbus_channel; 114 115int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, 116 struct hv_vmbus_channel *chan, netvsc_packet *pkt); 117void hv_rf_receive_rollup(netvsc_dev *net_dev); 118void hv_rf_channel_rollup(struct hv_vmbus_channel *chan); 119int hv_rf_on_device_add(struct hv_device *device, void *additl_info, int nchan); 120int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel); 121int hv_rf_on_open(struct hv_device *device); 122int hv_rf_on_close(struct hv_device *device); 123 124#endif /* __HV_RNDIS_FILTER_H__ */ 125 126