• 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-2009, 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  * $Id: bcmcdc.h,v 13.14.16.3.16.4 2009/04/12 16:58:45 Exp $
28  */
29 #include <proto/ethernet.h>
30 
31 typedef struct cdc_ioctl {
32 	uint32 cmd;      /* ioctl command value */
33 	uint32 len;      /* lower 16: output buflen; upper 16: input buflen (excludes header) */
34 	uint32 flags;    /* flag defns given below */
35 	uint32 status;   /* status code returned from the device */
36 } cdc_ioctl_t;
37 
38 /* Max valid buffer size that can be sent to the dongle */
39 #define CDC_MAX_MSG_SIZE   ETHER_MAX_LEN
40 
41 /* len field is divided into input and output buffer lengths */
42 #define CDCL_IOC_OUTLEN_MASK   0x0000FFFF  /* maximum or expected response length, */
43 					   /* excluding IOCTL header */
44 #define CDCL_IOC_OUTLEN_SHIFT  0
45 #define CDCL_IOC_INLEN_MASK    0xFFFF0000   /* input buffer length, excluding IOCTL header */
46 #define CDCL_IOC_INLEN_SHIFT   16
47 
48 /* CDC flag definitions */
49 #define CDCF_IOC_ERROR		0x01	/* 0=success, 1=ioctl cmd failed */
50 #define CDCF_IOC_SET		0x02	/* 0=get, 1=set cmd */
51 #define CDCF_IOC_IF_MASK	0xF000	/* I/F index */
52 #define CDCF_IOC_IF_SHIFT	12
53 #define CDCF_IOC_ID_MASK	0xFFFF0000	/* used to uniquely id an ioctl req/resp pairing */
54 #define CDCF_IOC_ID_SHIFT	16		/* # of bits of shift for ID Mask */
55 
56 #define CDC_IOC_IF_IDX(flags)	(((flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT)
57 #define CDC_IOC_ID(flags)	(((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT)
58 
59 #define CDC_GET_IF_IDX(hdr) \
60 	((int)((((hdr)->flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT))
61 #define CDC_SET_IF_IDX(hdr, idx) \
62 	((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | ((idx) << CDCF_IOC_IF_SHIFT)))
63 
64 /*
65  * BDC header
66  *
67  *   The BDC header is used on data packets to convey priority across USB.
68  */
69 
70 #define	BDC_HEADER_LEN		4
71 
72 #define BDC_PROTO_VER		1	/* Protocol version */
73 
74 #define BDC_FLAG_VER_MASK	0xf0	/* Protocol version mask */
75 #define BDC_FLAG_VER_SHIFT	4	/* Protocol version shift */
76 
77 #define BDC_FLAG__UNUSED	0x03	/* Unassigned */
78 #define BDC_FLAG_SUM_GOOD	0x04	/* Dongle has verified good RX checksums */
79 #define BDC_FLAG_SUM_NEEDED	0x08	/* Dongle needs to do TX checksums */
80 
81 #define BDC_PRIORITY_MASK	0x7
82 
83 #define BDC_FLAG2_FC_FLAG	0x10	/* flag to indicate if pkt contains */
84 									/* FLOW CONTROL info only */
85 #define BDC_PRIORITY_FC_SHIFT	4		/* flow control info shift */
86 
87 #define BDC_FLAG2_IF_MASK	0x0f	/* APSTA: interface on which the packet was received */
88 #define BDC_FLAG2_IF_SHIFT	0
89 
90 #define BDC_GET_IF_IDX(hdr) \
91 	((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT))
92 #define BDC_SET_IF_IDX(hdr, idx) \
93 	((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | ((idx) << BDC_FLAG2_IF_SHIFT)))
94 
95 struct bdc_header {
96 	uint8	flags;			/* Flags */
97 	uint8	priority;	/* 802.1d Priority 0:2 bits, 4:7 flow control info for usb */
98 	uint8	flags2;
99 	uint8	rssi;
100 };
101