Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / staging / brcm80211 / include / bcmcdc.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 #include <proto/ethernet.h>
17
18 typedef struct cdc_ioctl {
19         u32 cmd;                /* ioctl command value */
20         u32 len;                /* lower 16: output buflen; upper 16:
21                                  input buflen (excludes header) */
22         u32 flags;              /* flag defns given below */
23         u32 status;             /* status code returned from the device */
24 } cdc_ioctl_t;
25
26 /* Max valid buffer size that can be sent to the dongle */
27 #define CDC_MAX_MSG_SIZE   ETHER_MAX_LEN
28
29 /* len field is divided into input and output buffer lengths */
30 #define CDCL_IOC_OUTLEN_MASK   0x0000FFFF       /* maximum or expected
31                                                  response length, */
32                                            /* excluding IOCTL header */
33 #define CDCL_IOC_OUTLEN_SHIFT  0
34 #define CDCL_IOC_INLEN_MASK    0xFFFF0000       /* input buffer length,
35                                                  excluding IOCTL header */
36 #define CDCL_IOC_INLEN_SHIFT   16
37
38 /* CDC flag definitions */
39 #define CDCF_IOC_ERROR          0x01    /* 0=success, 1=ioctl cmd failed */
40 #define CDCF_IOC_SET            0x02    /* 0=get, 1=set cmd */
41 #define CDCF_IOC_IF_MASK        0xF000  /* I/F index */
42 #define CDCF_IOC_IF_SHIFT       12
43 #define CDCF_IOC_ID_MASK        0xFFFF0000      /* used to uniquely id an ioctl
44                                                  req/resp pairing */
45 #define CDCF_IOC_ID_SHIFT       16      /* # of bits of shift for ID Mask */
46
47 #define CDC_IOC_IF_IDX(flags)   \
48         (((flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT)
49 #define CDC_IOC_ID(flags)       \
50         (((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT)
51
52 #define CDC_GET_IF_IDX(hdr) \
53         ((int)((((hdr)->flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT))
54 #define CDC_SET_IF_IDX(hdr, idx) \
55         ((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | \
56         ((idx) << CDCF_IOC_IF_SHIFT)))
57
58 /*
59  * BDC header
60  *
61  *   The BDC header is used on data packets to convey priority across USB.
62  */
63
64 #define BDC_HEADER_LEN          4
65
66 #define BDC_PROTO_VER           1       /* Protocol version */
67
68 #define BDC_FLAG_VER_MASK       0xf0    /* Protocol version mask */
69 #define BDC_FLAG_VER_SHIFT      4       /* Protocol version shift */
70
71 #define BDC_FLAG__UNUSED        0x03    /* Unassigned */
72 #define BDC_FLAG_SUM_GOOD       0x04    /* Dongle has verified good
73                                          RX checksums */
74 #define BDC_FLAG_SUM_NEEDED     0x08    /* Dongle needs to do TX checksums */
75
76 #define BDC_PRIORITY_MASK       0x7
77
78 #define BDC_FLAG2_FC_FLAG       0x10    /* flag to indicate if pkt contains */
79                                                 /* FLOW CONTROL info only */
80 #define BDC_PRIORITY_FC_SHIFT   4       /* flow control info shift */
81
82 #define BDC_FLAG2_IF_MASK       0x0f    /* APSTA: interface on which the
83                                          packet was received */
84 #define BDC_FLAG2_IF_SHIFT      0
85
86 #define BDC_GET_IF_IDX(hdr) \
87         ((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT))
88 #define BDC_SET_IF_IDX(hdr, idx) \
89         ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | \
90         ((idx) << BDC_FLAG2_IF_SHIFT)))
91
92 struct bdc_header {
93         u8 flags;               /* Flags */
94         u8 priority;            /* 802.1d Priority 0:2 bits, 4:7 flow
95                                  control info for usb */
96         u8 flags2;
97         u8 rssi;
98 };