2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
16 #include <proto/ethernet.h>
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 */
26 /* Max valid buffer size that can be sent to the dongle */
27 #define CDC_MAX_MSG_SIZE ETHER_MAX_LEN
29 /* len field is divided into input and output buffer lengths */
30 #define CDCL_IOC_OUTLEN_MASK 0x0000FFFF /* maximum or expected
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
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
45 #define CDCF_IOC_ID_SHIFT 16 /* # of bits of shift for ID Mask */
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)
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)))
61 * The BDC header is used on data packets to convey priority across USB.
64 #define BDC_HEADER_LEN 4
66 #define BDC_PROTO_VER 1 /* Protocol version */
68 #define BDC_FLAG_VER_MASK 0xf0 /* Protocol version mask */
69 #define BDC_FLAG_VER_SHIFT 4 /* Protocol version shift */
71 #define BDC_FLAG__UNUSED 0x03 /* Unassigned */
72 #define BDC_FLAG_SUM_GOOD 0x04 /* Dongle has verified good
74 #define BDC_FLAG_SUM_NEEDED 0x08 /* Dongle needs to do TX checksums */
76 #define BDC_PRIORITY_MASK 0x7
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 */
82 #define BDC_FLAG2_IF_MASK 0x0f /* APSTA: interface on which the
83 packet was received */
84 #define BDC_FLAG2_IF_SHIFT 0
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)))
94 u8 priority
; /* 802.1d Priority 0:2 bits, 4:7 flow
95 control info for usb */