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