| 1 | /* |
| 2 | ***************************************************************************** |
| 3 | * |
| 4 | * FILE : unifi_clients.h |
| 5 | * |
| 6 | * PURPOSE : Private header file for unifi clients. |
| 7 | * |
| 8 | * UDI = UniFi Debug Interface |
| 9 | * |
| 10 | * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd. |
| 11 | * |
| 12 | * Refer to LICENSE.txt included with this source code for details on |
| 13 | * the license terms. |
| 14 | * |
| 15 | ***************************************************************************** |
| 16 | */ |
| 17 | #ifndef __LINUX_UNIFI_CLIENTS_H__ |
| 18 | #define __LINUX_UNIFI_CLIENTS_H__ 1 |
| 19 | |
| 20 | #include <linux/kernel.h> |
| 21 | |
| 22 | #define MAX_UDI_CLIENTS 8 |
| 23 | |
| 24 | /* The start of the range of process ids allocated for ul clients */ |
| 25 | #define UDI_SENDER_ID_BASE 0xC000 |
| 26 | #define UDI_SENDER_ID_SHIFT 8 |
| 27 | |
| 28 | |
| 29 | /* Structure to hold a UDI logged signal */ |
| 30 | typedef struct { |
| 31 | |
| 32 | /* List link structure */ |
| 33 | struct list_head q; |
| 34 | |
| 35 | /* The message that will be passed to the user app */ |
| 36 | udi_msg_t msg; |
| 37 | |
| 38 | /* Signal body and data follow */ |
| 39 | |
| 40 | } udi_log_t; |
| 41 | |
| 42 | |
| 43 | |
| 44 | typedef struct ul_client ul_client_t; |
| 45 | |
| 46 | typedef void (*udi_event_t)(ul_client_t *client, |
| 47 | const u8 *sigdata, int signal_len, |
| 48 | const bulk_data_param_t *bulkdata, |
| 49 | int dir); |
| 50 | |
| 51 | void logging_handler(void *ospriv, |
| 52 | u8 *sigdata, CsrUint32 signal_len, |
| 53 | const bulk_data_param_t *bulkdata, |
| 54 | enum udi_log_direction direction); |
| 55 | |
| 56 | |
| 57 | /* |
| 58 | * Structure describing a bulk data slot. |
| 59 | * The length field is used to indicate empty/occupied state. |
| 60 | */ |
| 61 | typedef struct _bulk_data |
| 62 | { |
| 63 | unsigned char ptr[2000]; |
| 64 | unsigned int length; |
| 65 | } bulk_data_t; |
| 66 | |
| 67 | |
| 68 | struct ul_client { |
| 69 | /* Index of this client in the ul_clients array. */ |
| 70 | int client_id; |
| 71 | |
| 72 | /* Index of UniFi device to which this client is attached. */ |
| 73 | int instance; |
| 74 | |
| 75 | /* Flag to say whether this client has been enabled. */ |
| 76 | int udi_enabled; |
| 77 | |
| 78 | /* Value to use in signal->SenderProcessId */ |
| 79 | int sender_id; |
| 80 | |
| 81 | /* Configuration flags, e.g blocking, logging, etc. */ |
| 82 | unsigned int configuration; |
| 83 | |
| 84 | udi_event_t event_hook; |
| 85 | |
| 86 | /* A list to hold signals received from UniFi for reading by read() */ |
| 87 | struct list_head udi_log; |
| 88 | |
| 89 | /* Semaphore to protect the udi_log list */ |
| 90 | struct semaphore udi_sem; |
| 91 | |
| 92 | /* |
| 93 | * Linux waitqueue to support blocking read and poll. |
| 94 | * Logging clients should wait on udi_log. while |
| 95 | * blocking clients should wait on wake_up_wq. |
| 96 | */ |
| 97 | wait_queue_head_t udi_wq; |
| 98 | CSR_SIGNAL* reply_signal; |
| 99 | bulk_data_t* reply_bulkdata[UNIFI_MAX_DATA_REFERENCES]; |
| 100 | |
| 101 | u16 signal_filter[SIG_FILTER_SIZE]; |
| 102 | |
| 103 | |
| 104 | /* ------------------------------------------------------------------- */ |
| 105 | /* Code below here is used by the sme_native configuration only */ |
| 106 | |
| 107 | /* Flag to wake up blocking clients waiting on udi_wq. */ |
| 108 | int wake_up_wq_id; |
| 109 | |
| 110 | /* |
| 111 | * A 0x00 - 0x0F mask to apply in signal->SenderProcessId. |
| 112 | * Every time we do a blocking mlme request we increase this value. |
| 113 | * The mlme_wait_for_reply() will wait for this sequence number. |
| 114 | * Only the MLME blocking functions update this field. |
| 115 | */ |
| 116 | unsigned char seq_no; |
| 117 | |
| 118 | /* |
| 119 | * A 0x00 - 0x0F counter, containing the sequence number of |
| 120 | * the signal that this client has last received. |
| 121 | * Only the MLME blocking functions update this field. |
| 122 | */ |
| 123 | unsigned char wake_seq_no; |
| 124 | |
| 125 | unifiio_snap_filter_t snap_filter; |
| 126 | }; /* struct ul_client */ |
| 127 | |
| 128 | |
| 129 | #endif /* __LINUX_UNIFI_CLIENTS_H__ */ |