• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * CDC network driver ioctl/indication encoding
3  * Broadcom 802.11abg Networking Device Driver
4  *
5  * Definitions subject to change without notice.
6  *
7  * Copyright (C) 1999-2017, Broadcom Corporation
8  *
9  *      Unless you and Broadcom execute a separate written software license
10  * agreement governing use of this software, this software is licensed to you
11  * under the terms of the GNU General Public License version 2 (the "GPL"),
12  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
13  * following added to such license:
14  *
15  *      As a special exception, the copyright holders of this software give you
16  * permission to link this software with independent modules, and to copy and
17  * distribute the resulting executable under terms of your choice, provided that
18  * you also meet, for each linked independent module, the terms and conditions of
19  * the license of that module.  An independent module is a module which is not
20  * derived from this software.  The special exception does not apply to any
21  * modifications of the software.
22  *
23  *      Notwithstanding the above, under no circumstances may you combine this
24  * software in any way with any other Broadcom software provided under a license
25  * other than the GPL, without Broadcom's express prior written consent.
26  *
27  *
28  * <<Broadcom-WL-IPTag/Open:>>
29  *
30  * $Id: bcmcdc.h 676811 2016-12-24 20:48:46Z $
31  */
32 #ifndef _bcmcdc_h_
33 #define    _bcmcdc_h_
34 #include <ethernet.h>
35 
36 typedef struct cdc_ioctl {
37     uint32 cmd;      /* ioctl command value */
38     uint32 len;      /* lower 16: output buflen; upper 16: input buflen (excludes header) */
39     uint32 flags;    /* flag defns given below */
40     uint32 status;   /* status code returned from the device */
41 } cdc_ioctl_t;
42 
43 /* Max valid buffer size that can be sent to the dongle */
44 #define CDC_MAX_MSG_SIZE   ETHER_MAX_LEN
45 
46 /* len field is divided into input and output buffer lengths */
47 #define CDCL_IOC_OUTLEN_MASK   0x0000FFFF  /* maximum or expected response length, */
48                        /* excluding IOCTL header */
49 #define CDCL_IOC_OUTLEN_SHIFT  0
50 #define CDCL_IOC_INLEN_MASK    0xFFFF0000   /* input buffer length, excluding IOCTL header */
51 #define CDCL_IOC_INLEN_SHIFT   16
52 
53 /* CDC flag definitions */
54 #define CDCF_IOC_ERROR        0x01    /* 0=success, 1=ioctl cmd failed */
55 #define CDCF_IOC_SET        0x02    /* 0=get, 1=set cmd */
56 #define CDCF_IOC_OVL_IDX_MASK    0x3c    /* overlay region index mask */
57 #define CDCF_IOC_OVL_RSV    0x40    /* 1=reserve this overlay region */
58 #define CDCF_IOC_OVL        0x80    /* 1=this ioctl corresponds to an overlay */
59 #define CDCF_IOC_ACTION_MASK    0xfe    /* SET/GET, OVL_IDX, OVL_RSV, OVL mask */
60 #define CDCF_IOC_ACTION_SHIFT    1    /* SET/GET, OVL_IDX, OVL_RSV, OVL shift */
61 #define CDCF_IOC_IF_MASK    0xF000    /* I/F index */
62 #define CDCF_IOC_IF_SHIFT    12
63 #define CDCF_IOC_ID_MASK    0xFFFF0000    /* used to uniquely id an ioctl req/resp pairing */
64 #define CDCF_IOC_ID_SHIFT    16        /* # of bits of shift for ID Mask */
65 
66 #define CDC_IOC_IF_IDX(flags)    (((flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT)
67 #define CDC_IOC_ID(flags)    (((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT)
68 
69 #define CDC_GET_IF_IDX(hdr) \
70     ((int)((((hdr)->flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT))
71 #define CDC_SET_IF_IDX(hdr, idx) \
72     ((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | ((idx) << CDCF_IOC_IF_SHIFT)))
73 
74 /*
75  * BDC header
76  *
77  *   The BDC header is used on data packets to convey priority across USB.
78  */
79 
80 struct bdc_header {
81     uint8    flags;            /* Flags */
82     uint8    priority;        /* 802.1d Priority 0:2 bits, 4:7 USB flow control info */
83     uint8    flags2;
84     uint8    dataOffset;        /* Offset from end of BDC header to packet data, in
85                      * 4-byte words.  Leaves room for optional headers.
86                      */
87 };
88 
89 #define    BDC_HEADER_LEN        4
90 
91 /* flags field bitmap */
92 #define BDC_FLAG_80211_PKT    0x01    /* Packet is in 802.11 format (dongle -> host) */
93 #define BDC_FLAG_SUM_GOOD    0x04    /* Dongle has verified good RX checksums */
94 #define BDC_FLAG_SUM_NEEDED    0x08    /* Dongle needs to do TX checksums: host->device */
95 #define BDC_FLAG_EVENT_MSG    0x08    /* Payload contains an event msg: device->host */
96 #define BDC_FLAG_VER_MASK    0xf0    /* Protocol version mask */
97 #define BDC_FLAG_VER_SHIFT    4    /* Protocol version shift */
98 
99 /* priority field bitmap */
100 #define BDC_PRIORITY_MASK    0x07
101 #define BDC_PRIORITY_FC_MASK    0xf0    /* flow control info mask */
102 #define BDC_PRIORITY_FC_SHIFT    4    /* flow control info shift */
103 
104 /* flags2 field bitmap */
105 #define BDC_FLAG2_IF_MASK    0x0f    /* interface index (host <-> dongle) */
106 #define BDC_FLAG2_IF_SHIFT    0
107 #define BDC_FLAG2_FC_FLAG    0x10    /* flag to indicate if pkt contains */
108                     /* FLOW CONTROL info only */
109 
110 /* version numbers */
111 #define BDC_PROTO_VER_1        1    /* Old Protocol version */
112 #define BDC_PROTO_VER        2    /* Protocol version */
113 
114 /* flags2.if field access macros */
115 #define BDC_GET_IF_IDX(hdr) \
116     ((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT))
117 #define BDC_SET_IF_IDX(hdr, idx) \
118     ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | ((idx) << BDC_FLAG2_IF_SHIFT)))
119 
120 #define BDC_FLAG2_PAD_MASK        0xf0
121 #define BDC_FLAG_PAD_MASK        0x03
122 #define BDC_FLAG2_PAD_SHIFT        2
123 #define BDC_FLAG_PAD_SHIFT        0
124 #define BDC_FLAG2_PAD_IDX        0x3c
125 #define BDC_FLAG_PAD_IDX        0x03
126 #define BDC_GET_PAD_LEN(hdr) \
127     ((int)(((((hdr)->flags2) & BDC_FLAG2_PAD_MASK) >> BDC_FLAG2_PAD_SHIFT) | \
128     ((((hdr)->flags) & BDC_FLAG_PAD_MASK) >> BDC_FLAG_PAD_SHIFT)))
129 #define BDC_SET_PAD_LEN(hdr, idx) \
130     ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_PAD_MASK) | \
131     (((idx) & BDC_FLAG2_PAD_IDX) << BDC_FLAG2_PAD_SHIFT))); \
132     ((hdr)->flags = (((hdr)->flags & ~BDC_FLAG_PAD_MASK) | \
133     (((idx) & BDC_FLAG_PAD_IDX) << BDC_FLAG_PAD_SHIFT)))
134 
135 #endif /* _bcmcdc_h_ */
136