Resync with broadcom drivers 5.100.138.20 and utilities.
[tomato.git] / release / src-rt / include / bcmcdc.h
bloba194b24708849cb8a2d7ab7af8e370a4090707fc
1 /*
2 * CDC network driver ioctl/indication encoding
3 * Broadcom 802.11abg Networking Device Driver
5 * Definitions subject to change without notice.
7 * Copyright (C) 2010, Broadcom Corporation. All Rights Reserved.
8 *
9 * Permission to use, copy, modify, and/or distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
16 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * $Id: bcmcdc.h,v 13.25 2009-09-23 22:40:26 Exp $
23 #ifndef _bcmcdc_h_
24 #define _bcmcdc_h_
25 #include <proto/ethernet.h>
27 typedef struct cdc_ioctl {
28 uint32 cmd; /* ioctl command value */
29 uint32 len; /* lower 16: output buflen; upper 16: input buflen (excludes header) */
30 uint32 flags; /* flag defns given below */
31 uint32 status; /* status code returned from the device */
32 } cdc_ioctl_t;
34 /* Max valid buffer size that can be sent to the dongle */
35 #define CDC_MAX_MSG_SIZE ETHER_MAX_LEN
37 /* len field is divided into input and output buffer lengths */
38 #define CDCL_IOC_OUTLEN_MASK 0x0000FFFF /* maximum or expected response length, */
39 /* excluding IOCTL header */
40 #define CDCL_IOC_OUTLEN_SHIFT 0
41 #define CDCL_IOC_INLEN_MASK 0xFFFF0000 /* input buffer length, excluding IOCTL header */
42 #define CDCL_IOC_INLEN_SHIFT 16
44 /* CDC flag definitions */
45 #define CDCF_IOC_ERROR 0x01 /* 0=success, 1=ioctl cmd failed */
46 #define CDCF_IOC_SET 0x02 /* 0=get, 1=set cmd */
47 #define CDCF_IOC_IF_MASK 0xF000 /* I/F index */
48 #define CDCF_IOC_IF_SHIFT 12
49 #define CDCF_IOC_ID_MASK 0xFFFF0000 /* used to uniquely id an ioctl req/resp pairing */
50 #define CDCF_IOC_ID_SHIFT 16 /* # of bits of shift for ID Mask */
52 #define CDC_IOC_IF_IDX(flags) (((flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT)
53 #define CDC_IOC_ID(flags) (((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT)
55 #define CDC_GET_IF_IDX(hdr) \
56 ((int)((((hdr)->flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT))
57 #define CDC_SET_IF_IDX(hdr, idx) \
58 ((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | ((idx) << CDCF_IOC_IF_SHIFT)))
61 * BDC header
63 * The BDC header is used on data packets to convey priority across USB.
66 #define BDC_HEADER_LEN 4
68 #define BDC_PROTO_VER 2 /* Protocol version */
70 #define BDC_FLAG_VER_MASK 0xf0 /* Protocol version mask */
71 #define BDC_FLAG_VER_SHIFT 4 /* Protocol version shift */
73 #define BDC_FLAG__UNUSED 0x03 /* Unassigned */
74 #define BDC_FLAG_SUM_GOOD 0x04 /* Dongle has verified good RX checksums */
75 #define BDC_FLAG_SUM_NEEDED 0x08 /* Dongle needs to do TX checksums */
77 #define BDC_PRIORITY_MASK 0x7
79 #define BDC_FLAG2_IF_MASK 0x0f /* APSTA: interface on which the packet was received */
80 #define BDC_FLAG2_IF_SHIFT 0
82 #define BDC_GET_IF_IDX(hdr) \
83 ((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT))
84 #define BDC_SET_IF_IDX(hdr, idx) \
85 ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | ((idx) << BDC_FLAG2_IF_SHIFT)))
87 struct bdc_header {
88 uint8 flags; /* Flags */
89 uint8 priority; /* 802.1d Priority (low 3 bits) */
90 uint8 flags2;
91 uint8 dataOffset; /* Offset from end of BDC header to packet data, in
92 * 4-byte words. Leaves room for optional headers.
96 #define BDC_PROTO_VER_1 1 /* Old Protocol version */
98 #endif /* _bcmcdc_h_ */