• Home
  • History
  • Annotate
  • 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-2013, Broadcom Corporation
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.
12   *
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.
20   *
21   * $Id: bcmcdc.h 318308 2012-03-02 02:23:42Z $
22   */
23  #ifndef _bcmcdc_h_
24  #define	_bcmcdc_h_
25  #include <proto/ethernet.h>
26  
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;
33  
34  /* Max valid buffer size that can be sent to the dongle */
35  #define CDC_MAX_MSG_SIZE   ETHER_MAX_LEN
36  
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
43  
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_OVL_IDX_MASK	0x3c	/* overlay region index mask */
48  #define CDCF_IOC_OVL_RSV	0x40	/* 1=reserve this overlay region */
49  #define CDCF_IOC_OVL		0x80	/* 1=this ioctl corresponds to an overlay */
50  #define CDCF_IOC_ACTION_MASK	0xfe	/* SET/GET, OVL_IDX, OVL_RSV, OVL mask */
51  #define CDCF_IOC_ACTION_SHIFT	1	/* SET/GET, OVL_IDX, OVL_RSV, OVL shift */
52  #define CDCF_IOC_IF_MASK	0xF000	/* I/F index */
53  #define CDCF_IOC_IF_SHIFT	12
54  #define CDCF_IOC_ID_MASK	0xFFFF0000	/* used to uniquely id an ioctl req/resp pairing */
55  #define CDCF_IOC_ID_SHIFT	16		/* # of bits of shift for ID Mask */
56  
57  #define CDC_IOC_IF_IDX(flags)	(((flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT)
58  #define CDC_IOC_ID(flags)	(((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT)
59  
60  #define CDC_GET_IF_IDX(hdr) \
61  	((int)((((hdr)->flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT))
62  #define CDC_SET_IF_IDX(hdr, idx) \
63  	((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | ((idx) << CDCF_IOC_IF_SHIFT)))
64  
65  /*
66   * BDC header
67   *
68   *   The BDC header is used on data packets to convey priority across USB.
69   */
70  
71  struct bdc_header {
72  	uint8	flags;			/* Flags */
73  	uint8	priority;		/* 802.1d Priority 0:2 bits, 4:7 USB flow control info */
74  	uint8	flags2;
75  	uint8	dataOffset;		/* Offset from end of BDC header to packet data, in
76  					 * 4-byte words.  Leaves room for optional headers.
77  					 */
78  };
79  
80  #define	BDC_HEADER_LEN		4
81  
82  /* flags field bitmap */
83  #define BDC_FLAG_80211_PKT	0x01	/* Packet is in 802.11 format (dongle -> host) */
84  #define BDC_FLAG_SUM_GOOD	0x04	/* Dongle has verified good RX checksums */
85  #define BDC_FLAG_SUM_NEEDED	0x08	/* Dongle needs to do TX checksums: host->device */
86  #define BDC_FLAG_EVENT_MSG	0x08	/* Payload contains an event msg: device->host */
87  #define BDC_FLAG_VER_MASK	0xf0	/* Protocol version mask */
88  #define BDC_FLAG_VER_SHIFT	4	/* Protocol version shift */
89  
90  /* priority field bitmap */
91  #define BDC_PRIORITY_MASK	0x07
92  #define BDC_PRIORITY_FC_MASK	0xf0	/* flow control info mask */
93  #define BDC_PRIORITY_FC_SHIFT	4	/* flow control info shift */
94  
95  /* flags2 field bitmap */
96  #define BDC_FLAG2_IF_MASK	0x0f	/* interface index (host <-> dongle) */
97  #define BDC_FLAG2_IF_SHIFT	0
98  #define BDC_FLAG2_FC_FLAG	0x10	/* flag to indicate if pkt contains */
99  					/* FLOW CONTROL info only */
100  
101  /* version numbers */
102  #define BDC_PROTO_VER_1		1	/* Old Protocol version */
103  #define BDC_PROTO_VER		2	/* Protocol version */
104  
105  /* flags2.if field access macros */
106  #define BDC_GET_IF_IDX(hdr) \
107  	((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT))
108  #define BDC_SET_IF_IDX(hdr, idx) \
109  	((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | ((idx) << BDC_FLAG2_IF_SHIFT)))
110  
111  #define BDC_FLAG2_PAD_MASK		0xf0
112  #define BDC_FLAG_PAD_MASK		0x03
113  #define BDC_FLAG2_PAD_SHIFT		2
114  #define BDC_FLAG_PAD_SHIFT		0
115  #define BDC_FLAG2_PAD_IDX		0x3c
116  #define BDC_FLAG_PAD_IDX		0x03
117  #define BDC_GET_PAD_LEN(hdr) \
118  	((int)(((((hdr)->flags2) & BDC_FLAG2_PAD_MASK) >> BDC_FLAG2_PAD_SHIFT) | \
119  	((((hdr)->flags) & BDC_FLAG_PAD_MASK) >> BDC_FLAG_PAD_SHIFT)))
120  #define BDC_SET_PAD_LEN(hdr, idx) \
121  	((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_PAD_MASK) | \
122  	(((idx) & BDC_FLAG2_PAD_IDX) << BDC_FLAG2_PAD_SHIFT))); \
123  	((hdr)->flags = (((hdr)->flags & ~BDC_FLAG_PAD_MASK) | \
124  	(((idx) & BDC_FLAG_PAD_IDX) << BDC_FLAG_PAD_SHIFT)))
125  
126  #endif /* _bcmcdc_h_ */
127