uboot/drivers/usb/gadget/rndis.h
<<
>>
Prefs
   1/*
   2 * RNDIS        Definitions for Remote NDIS
   3 *
   4 * Authors:     Benedikt Spranger, Pengutronix
   5 *              Robert Schwebel, Pengutronix
   6 *
   7 *              This program is free software; you can redistribute it and/or
   8 *              modify it under the terms of the GNU General Public License
   9 *              version 2, as published by the Free Software Foundation.
  10 *
  11 *              This software was originally developed in conformance with
  12 *              Microsoft's Remote NDIS Specification License Agreement.
  13 */
  14
  15#ifndef _USBGADGET_RNDIS_H
  16#define _USBGADGET_RNDIS_H
  17
  18#include "ndis.h"
  19
  20/*
  21 * By default rndis_signal_disconnect does not send status message about
  22 * RNDIS disconnection to USB host (indicated as cable disconnected).
  23 * Define RNDIS_COMPLETE_SIGNAL_DISCONNECT to send it.
  24 * However, this will cause 1 sec delay on Ethernet device halt.
  25 * Usually you do not need to define it. Mostly usable for debugging.
  26 */
  27
  28#define RNDIS_MAXIMUM_FRAME_SIZE        1518
  29#define RNDIS_MAX_TOTAL_SIZE            1558
  30
  31/* Remote NDIS Versions */
  32#define RNDIS_MAJOR_VERSION             1
  33#define RNDIS_MINOR_VERSION             0
  34
  35/* Status Values */
  36#define RNDIS_STATUS_SUCCESS            0x00000000U     /* Success           */
  37#define RNDIS_STATUS_FAILURE            0xC0000001U     /* Unspecified error */
  38#define RNDIS_STATUS_INVALID_DATA       0xC0010015U     /* Invalid data      */
  39#define RNDIS_STATUS_NOT_SUPPORTED      0xC00000BBU     /* Unsupported request */
  40#define RNDIS_STATUS_MEDIA_CONNECT      0x4001000BU     /* Device connected  */
  41#define RNDIS_STATUS_MEDIA_DISCONNECT   0x4001000CU     /* Device disconnected */
  42/*
  43 * For all not specified status messages:
  44 * RNDIS_STATUS_Xxx -> NDIS_STATUS_Xxx
  45 */
  46
  47/* Message Set for Connectionless (802.3) Devices */
  48#define REMOTE_NDIS_PACKET_MSG          0x00000001U
  49#define REMOTE_NDIS_INITIALIZE_MSG      0x00000002U     /* Initialize device */
  50#define REMOTE_NDIS_HALT_MSG            0x00000003U
  51#define REMOTE_NDIS_QUERY_MSG           0x00000004U
  52#define REMOTE_NDIS_SET_MSG             0x00000005U
  53#define REMOTE_NDIS_RESET_MSG           0x00000006U
  54#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007U
  55#define REMOTE_NDIS_KEEPALIVE_MSG       0x00000008U
  56
  57/* Message completion */
  58#define REMOTE_NDIS_INITIALIZE_CMPLT    0x80000002U
  59#define REMOTE_NDIS_QUERY_CMPLT         0x80000004U
  60#define REMOTE_NDIS_SET_CMPLT           0x80000005U
  61#define REMOTE_NDIS_RESET_CMPLT         0x80000006U
  62#define REMOTE_NDIS_KEEPALIVE_CMPLT     0x80000008U
  63
  64/* Device Flags */
  65#define RNDIS_DF_CONNECTIONLESS         0x00000001U
  66#define RNDIS_DF_CONNECTION_ORIENTED    0x00000002U
  67
  68#define RNDIS_MEDIUM_802_3              0x00000000U
  69
  70/* from drivers/net/sk98lin/h/skgepnmi.h */
  71#define OID_PNP_CAPABILITIES                    0xFD010100
  72#define OID_PNP_SET_POWER                       0xFD010101
  73#define OID_PNP_QUERY_POWER                     0xFD010102
  74#define OID_PNP_ADD_WAKE_UP_PATTERN             0xFD010103
  75#define OID_PNP_REMOVE_WAKE_UP_PATTERN          0xFD010104
  76#define OID_PNP_ENABLE_WAKE_UP                  0xFD010106
  77
  78
  79typedef struct rndis_init_msg_type {
  80        __le32  MessageType;
  81        __le32  MessageLength;
  82        __le32  RequestID;
  83        __le32  MajorVersion;
  84        __le32  MinorVersion;
  85        __le32  MaxTransferSize;
  86} rndis_init_msg_type;
  87
  88typedef struct rndis_init_cmplt_type {
  89        __le32  MessageType;
  90        __le32  MessageLength;
  91        __le32  RequestID;
  92        __le32  Status;
  93        __le32  MajorVersion;
  94        __le32  MinorVersion;
  95        __le32  DeviceFlags;
  96        __le32  Medium;
  97        __le32  MaxPacketsPerTransfer;
  98        __le32  MaxTransferSize;
  99        __le32  PacketAlignmentFactor;
 100        __le32  AFListOffset;
 101        __le32  AFListSize;
 102} rndis_init_cmplt_type;
 103
 104typedef struct rndis_halt_msg_type {
 105        __le32  MessageType;
 106        __le32  MessageLength;
 107        __le32  RequestID;
 108} rndis_halt_msg_type;
 109
 110typedef struct rndis_query_msg_type {
 111        __le32  MessageType;
 112        __le32  MessageLength;
 113        __le32  RequestID;
 114        __le32  OID;
 115        __le32  InformationBufferLength;
 116        __le32  InformationBufferOffset;
 117        __le32  DeviceVcHandle;
 118} rndis_query_msg_type;
 119
 120typedef struct rndis_query_cmplt_type {
 121        __le32  MessageType;
 122        __le32  MessageLength;
 123        __le32  RequestID;
 124        __le32  Status;
 125        __le32  InformationBufferLength;
 126        __le32  InformationBufferOffset;
 127} rndis_query_cmplt_type;
 128
 129typedef struct rndis_set_msg_type {
 130        __le32  MessageType;
 131        __le32  MessageLength;
 132        __le32  RequestID;
 133        __le32  OID;
 134        __le32  InformationBufferLength;
 135        __le32  InformationBufferOffset;
 136        __le32  DeviceVcHandle;
 137} rndis_set_msg_type;
 138
 139typedef struct rndis_set_cmplt_type {
 140        __le32  MessageType;
 141        __le32  MessageLength;
 142        __le32  RequestID;
 143        __le32  Status;
 144} rndis_set_cmplt_type;
 145
 146typedef struct rndis_reset_msg_type {
 147        __le32  MessageType;
 148        __le32  MessageLength;
 149        __le32  Reserved;
 150} rndis_reset_msg_type;
 151
 152typedef struct rndis_reset_cmplt_type {
 153        __le32  MessageType;
 154        __le32  MessageLength;
 155        __le32  Status;
 156        __le32  AddressingReset;
 157} rndis_reset_cmplt_type;
 158
 159typedef struct rndis_indicate_status_msg_type {
 160        __le32  MessageType;
 161        __le32  MessageLength;
 162        __le32  Status;
 163        __le32  StatusBufferLength;
 164        __le32  StatusBufferOffset;
 165} rndis_indicate_status_msg_type;
 166
 167typedef struct rndis_keepalive_msg_type {
 168        __le32  MessageType;
 169        __le32  MessageLength;
 170        __le32  RequestID;
 171} rndis_keepalive_msg_type;
 172
 173typedef struct rndis_keepalive_cmplt_type {
 174        __le32  MessageType;
 175        __le32  MessageLength;
 176        __le32  RequestID;
 177        __le32  Status;
 178} rndis_keepalive_cmplt_type;
 179
 180struct rndis_packet_msg_type {
 181        __le32  MessageType;
 182        __le32  MessageLength;
 183        __le32  DataOffset;
 184        __le32  DataLength;
 185        __le32  OOBDataOffset;
 186        __le32  OOBDataLength;
 187        __le32  NumOOBDataElements;
 188        __le32  PerPacketInfoOffset;
 189        __le32  PerPacketInfoLength;
 190        __le32  VcHandle;
 191        __le32  Reserved;
 192} __attribute__ ((packed));
 193
 194struct rndis_config_parameter {
 195        __le32  ParameterNameOffset;
 196        __le32  ParameterNameLength;
 197        __le32  ParameterType;
 198        __le32  ParameterValueOffset;
 199        __le32  ParameterValueLength;
 200};
 201
 202/* implementation specific */
 203enum rndis_state {
 204        RNDIS_UNINITIALIZED,
 205        RNDIS_INITIALIZED,
 206        RNDIS_DATA_INITIALIZED,
 207};
 208
 209typedef struct rndis_resp_t {
 210        struct list_head        list;
 211        u8                      *buf;
 212        u32                     length;
 213        int                     send;
 214} rndis_resp_t;
 215
 216typedef struct rndis_params {
 217        u8                      confignr;
 218        u8                      used;
 219        u16                     saved_filter;
 220        enum rndis_state        state;
 221        u32                     medium;
 222        u32                     speed;
 223        u32                     media_state;
 224
 225        const u8                *host_mac;
 226        u16                     *filter;
 227        struct eth_device       *dev;
 228        struct net_device_stats *stats;
 229        int                     mtu;
 230
 231        u32                     vendorID;
 232        const char              *vendorDescr;
 233        int                     (*ack)(struct eth_device *);
 234        struct list_head        resp_queue;
 235} rndis_params;
 236
 237/* RNDIS Message parser and other useless functions */
 238int  rndis_msg_parser(u8 configNr, u8 *buf);
 239enum rndis_state rndis_get_state(int configNr);
 240int  rndis_register(int (*rndis_control_ack)(struct eth_device *));
 241void rndis_deregister(int configNr);
 242int  rndis_set_param_dev(u8 configNr, struct eth_device *dev, int mtu,
 243                        struct net_device_stats *stats, u16 *cdc_filter);
 244int  rndis_set_param_vendor(u8 configNr, u32 vendorID,
 245                            const char *vendorDescr);
 246int  rndis_set_param_medium(u8 configNr, u32 medium, u32 speed);
 247void rndis_add_hdr(void *bug, int length);
 248int rndis_rm_hdr(void *bug, int length);
 249u8   *rndis_get_next_response(int configNr, u32 *length);
 250void rndis_free_response(int configNr, u8 *buf);
 251
 252void rndis_uninit(int configNr);
 253int  rndis_signal_connect(int configNr);
 254int  rndis_signal_disconnect(int configNr);
 255extern void rndis_set_host_mac(int configNr, const u8 *addr);
 256
 257int rndis_init(void);
 258void rndis_exit(void);
 259
 260#endif  /* _USBGADGET_RNDIS_H */
 261