root/drivers/usb/gadget/function/rndis.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 // SPDX-License-Identifier: GPL-2.0
   2 /*
   3  * RNDIS        Definitions for Remote NDIS
   4  *
   5  * Authors:     Benedikt Spranger, Pengutronix
   6  *              Robert Schwebel, Pengutronix
   7  *
   8  *              This software was originally developed in conformance with
   9  *              Microsoft's Remote NDIS Specification License Agreement.
  10  */
  11 
  12 #ifndef _LINUX_RNDIS_H
  13 #define _LINUX_RNDIS_H
  14 
  15 #include <linux/rndis.h>
  16 #include "u_ether.h"
  17 #include "ndis.h"
  18 
  19 #define RNDIS_MAXIMUM_FRAME_SIZE        1518
  20 #define RNDIS_MAX_TOTAL_SIZE            1558
  21 
  22 typedef struct rndis_init_msg_type {
  23         __le32  MessageType;
  24         __le32  MessageLength;
  25         __le32  RequestID;
  26         __le32  MajorVersion;
  27         __le32  MinorVersion;
  28         __le32  MaxTransferSize;
  29 } rndis_init_msg_type;
  30 
  31 typedef struct rndis_init_cmplt_type {
  32         __le32  MessageType;
  33         __le32  MessageLength;
  34         __le32  RequestID;
  35         __le32  Status;
  36         __le32  MajorVersion;
  37         __le32  MinorVersion;
  38         __le32  DeviceFlags;
  39         __le32  Medium;
  40         __le32  MaxPacketsPerTransfer;
  41         __le32  MaxTransferSize;
  42         __le32  PacketAlignmentFactor;
  43         __le32  AFListOffset;
  44         __le32  AFListSize;
  45 } rndis_init_cmplt_type;
  46 
  47 typedef struct rndis_halt_msg_type {
  48         __le32  MessageType;
  49         __le32  MessageLength;
  50         __le32  RequestID;
  51 } rndis_halt_msg_type;
  52 
  53 typedef struct rndis_query_msg_type {
  54         __le32  MessageType;
  55         __le32  MessageLength;
  56         __le32  RequestID;
  57         __le32  OID;
  58         __le32  InformationBufferLength;
  59         __le32  InformationBufferOffset;
  60         __le32  DeviceVcHandle;
  61 } rndis_query_msg_type;
  62 
  63 typedef struct rndis_query_cmplt_type {
  64         __le32  MessageType;
  65         __le32  MessageLength;
  66         __le32  RequestID;
  67         __le32  Status;
  68         __le32  InformationBufferLength;
  69         __le32  InformationBufferOffset;
  70 } rndis_query_cmplt_type;
  71 
  72 typedef struct rndis_set_msg_type {
  73         __le32  MessageType;
  74         __le32  MessageLength;
  75         __le32  RequestID;
  76         __le32  OID;
  77         __le32  InformationBufferLength;
  78         __le32  InformationBufferOffset;
  79         __le32  DeviceVcHandle;
  80 } rndis_set_msg_type;
  81 
  82 typedef struct rndis_set_cmplt_type {
  83         __le32  MessageType;
  84         __le32  MessageLength;
  85         __le32  RequestID;
  86         __le32  Status;
  87 } rndis_set_cmplt_type;
  88 
  89 typedef struct rndis_reset_msg_type {
  90         __le32  MessageType;
  91         __le32  MessageLength;
  92         __le32  Reserved;
  93 } rndis_reset_msg_type;
  94 
  95 typedef struct rndis_reset_cmplt_type {
  96         __le32  MessageType;
  97         __le32  MessageLength;
  98         __le32  Status;
  99         __le32  AddressingReset;
 100 } rndis_reset_cmplt_type;
 101 
 102 typedef struct rndis_indicate_status_msg_type {
 103         __le32  MessageType;
 104         __le32  MessageLength;
 105         __le32  Status;
 106         __le32  StatusBufferLength;
 107         __le32  StatusBufferOffset;
 108 } rndis_indicate_status_msg_type;
 109 
 110 typedef struct rndis_keepalive_msg_type {
 111         __le32  MessageType;
 112         __le32  MessageLength;
 113         __le32  RequestID;
 114 } rndis_keepalive_msg_type;
 115 
 116 typedef struct rndis_keepalive_cmplt_type {
 117         __le32  MessageType;
 118         __le32  MessageLength;
 119         __le32  RequestID;
 120         __le32  Status;
 121 } rndis_keepalive_cmplt_type;
 122 
 123 struct rndis_packet_msg_type {
 124         __le32  MessageType;
 125         __le32  MessageLength;
 126         __le32  DataOffset;
 127         __le32  DataLength;
 128         __le32  OOBDataOffset;
 129         __le32  OOBDataLength;
 130         __le32  NumOOBDataElements;
 131         __le32  PerPacketInfoOffset;
 132         __le32  PerPacketInfoLength;
 133         __le32  VcHandle;
 134         __le32  Reserved;
 135 } __attribute__ ((packed));
 136 
 137 struct rndis_config_parameter {
 138         __le32  ParameterNameOffset;
 139         __le32  ParameterNameLength;
 140         __le32  ParameterType;
 141         __le32  ParameterValueOffset;
 142         __le32  ParameterValueLength;
 143 };
 144 
 145 /* implementation specific */
 146 enum rndis_state {
 147         RNDIS_UNINITIALIZED,
 148         RNDIS_INITIALIZED,
 149         RNDIS_DATA_INITIALIZED,
 150 };
 151 
 152 typedef struct rndis_resp_t {
 153         struct list_head        list;
 154         u8                      *buf;
 155         u32                     length;
 156         int                     send;
 157 } rndis_resp_t;
 158 
 159 typedef struct rndis_params {
 160         int                     confignr;
 161         u8                      used;
 162         u16                     saved_filter;
 163         enum rndis_state        state;
 164         u32                     medium;
 165         u32                     speed;
 166         u32                     media_state;
 167 
 168         const u8                *host_mac;
 169         u16                     *filter;
 170         struct net_device       *dev;
 171 
 172         u32                     vendorID;
 173         const char              *vendorDescr;
 174         void                    (*resp_avail)(void *v);
 175         void                    *v;
 176         struct list_head        resp_queue;
 177 } rndis_params;
 178 
 179 /* RNDIS Message parser and other useless functions */
 180 int  rndis_msg_parser(struct rndis_params *params, u8 *buf);
 181 struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v);
 182 void rndis_deregister(struct rndis_params *params);
 183 int  rndis_set_param_dev(struct rndis_params *params, struct net_device *dev,
 184                          u16 *cdc_filter);
 185 int  rndis_set_param_vendor(struct rndis_params *params, u32 vendorID,
 186                             const char *vendorDescr);
 187 int  rndis_set_param_medium(struct rndis_params *params, u32 medium,
 188                              u32 speed);
 189 void rndis_add_hdr(struct sk_buff *skb);
 190 int rndis_rm_hdr(struct gether *port, struct sk_buff *skb,
 191                         struct sk_buff_head *list);
 192 u8   *rndis_get_next_response(struct rndis_params *params, u32 *length);
 193 void rndis_free_response(struct rndis_params *params, u8 *buf);
 194 
 195 void rndis_uninit(struct rndis_params *params);
 196 int  rndis_signal_connect(struct rndis_params *params);
 197 int  rndis_signal_disconnect(struct rndis_params *params);
 198 int  rndis_state(struct rndis_params *params);
 199 extern void rndis_set_host_mac(struct rndis_params *params, const u8 *addr);
 200 
 201 #endif  /* _LINUX_RNDIS_H */

/* [<][>][^][v][top][bottom][index][help] */