1*49901133SHans Petter Selasky /* $FreeBSD$ */ 2*49901133SHans Petter Selasky 3*49901133SHans Petter Selasky /*- 4*49901133SHans Petter Selasky * Copyright (c) 2011 Anybots Inc 5*49901133SHans Petter Selasky * written by Akinori Furukoshi <moonlightakkiy@yahoo.ca> 6*49901133SHans Petter Selasky * - ucom part is based on u3g.c 7*49901133SHans Petter Selasky * 8*49901133SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 9*49901133SHans Petter Selasky * modification, are permitted provided that the following conditions 10*49901133SHans Petter Selasky * are met: 11*49901133SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 12*49901133SHans Petter Selasky * notice, this list of conditions and the following disclaimer. 13*49901133SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 14*49901133SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 15*49901133SHans Petter Selasky * documentation and/or other materials provided with the distribution. 16*49901133SHans Petter Selasky * 17*49901133SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18*49901133SHans Petter Selasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*49901133SHans Petter Selasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*49901133SHans Petter Selasky * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21*49901133SHans Petter Selasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*49901133SHans Petter Selasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*49901133SHans Petter Selasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*49901133SHans Petter Selasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*49901133SHans Petter Selasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*49901133SHans Petter Selasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*49901133SHans Petter Selasky * SUCH DAMAGE. 28*49901133SHans Petter Selasky */ 29*49901133SHans Petter Selasky 30*49901133SHans Petter Selasky #ifndef _IF_USEVAR_H_ 31*49901133SHans Petter Selasky #define _IF_USEVAR_H_ 32*49901133SHans Petter Selasky 33*49901133SHans Petter Selasky #define USIE_DCD 0x0001 34*49901133SHans Petter Selasky #define USIE_DSR 0x0002 35*49901133SHans Petter Selasky #define USIE_DTR 0x0004 36*49901133SHans Petter Selasky #define USIE_RI 0x0008 37*49901133SHans Petter Selasky #define USIE_CTS 0x0100 38*49901133SHans Petter Selasky #define USIE_RTS 0x0200 39*49901133SHans Petter Selasky 40*49901133SHans Petter Selasky #define USIE_HIP_FRM_CHR 0x7e 41*49901133SHans Petter Selasky #define USIE_HIP_ESC_CHR 0x7d 42*49901133SHans Petter Selasky #define USIE_HIP_IF 0 43*49901133SHans Petter Selasky 44*49901133SHans Petter Selasky #define USIE_HIPCNS_MIN 16 /* HIP + CnS + 2 framing char */ 45*49901133SHans Petter Selasky #define USIE_HIPCNS_MAX 261 /* HIP + max CnS 255 + 2 framing char */ 46*49901133SHans Petter Selasky 47*49901133SHans Petter Selasky #define USIE_CNFG_INDEX 0 48*49901133SHans Petter Selasky #define USIE_IFACE_INDEX 0 49*49901133SHans Petter Selasky #define USIE_IFACE_MAX 12 50*49901133SHans Petter Selasky #define USIE_BUFSIZE 2048 51*49901133SHans Petter Selasky #define USIE_MTU_MAX 1500 52*49901133SHans Petter Selasky #define USIE_RXSZ_MAX 4096 53*49901133SHans Petter Selasky 54*49901133SHans Petter Selasky /* USB control pipe request */ 55*49901133SHans Petter Selasky #define USIE_POWER 0x00 56*49901133SHans Petter Selasky #define USIE_FW_ATTR 0x06 57*49901133SHans Petter Selasky #define USIE_NMEA 0x07 58*49901133SHans Petter Selasky #define USIE_LINK_STATE 0x22 59*49901133SHans Petter Selasky 60*49901133SHans Petter Selasky /* firmware attr flags */ 61*49901133SHans Petter Selasky #define USIE_PM_AUTO (1 << 1) 62*49901133SHans Petter Selasky #define USIE_FW_DHCP (1 << 3) /* DHCP capable */ 63*49901133SHans Petter Selasky 64*49901133SHans Petter Selasky /* line state flags */ 65*49901133SHans Petter Selasky #define USIE_LS_DTR (1 << 0) 66*49901133SHans Petter Selasky #define USIE_LS_RTS (1 << 1) 67*49901133SHans Petter Selasky 68*49901133SHans Petter Selasky /* Host Interface Porotocol Header */ 69*49901133SHans Petter Selasky struct usie_hip { 70*49901133SHans Petter Selasky uint16_t len; 71*49901133SHans Petter Selasky #define USIE_HIP_LEN_MASK 0x3fff 72*49901133SHans Petter Selasky #define USIE_HIP_IP_LEN_MASK 0x07ff 73*49901133SHans Petter Selasky 74*49901133SHans Petter Selasky uint8_t id; 75*49901133SHans Petter Selasky #define USIE_HIP_PAD (1 << 7) 76*49901133SHans Petter Selasky #define USIE_HIP_MASK 0x7f 77*49901133SHans Petter Selasky #define USIE_HIP_SYNC2M 0x20 /* host -> modem */ 78*49901133SHans Petter Selasky #define USIE_HIP_DOWN 0x26 79*49901133SHans Petter Selasky #define USIE_HIP_CNS2M 0x2b /* h -> m */ 80*49901133SHans Petter Selasky #define USIE_HIP_CTX 0x3f 81*49901133SHans Petter Selasky #define USIE_HIP_SYNC2H 0x60 /* h <- m */ 82*49901133SHans Petter Selasky #define USIE_HIP_RESTR 0x62 83*49901133SHans Petter Selasky #define USIE_HIP_RCGI 0x64 84*49901133SHans Petter Selasky #define USIE_HIP_CNS2H 0x6b /* h <- m */ 85*49901133SHans Petter Selasky #define USIE_HIP_UMTS 0x78 86*49901133SHans Petter Selasky #define USIE_HIP_IP 0x7f 87*49901133SHans Petter Selasky 88*49901133SHans Petter Selasky uint8_t param; 89*49901133SHans Petter Selasky } __packed __aligned(4); 90*49901133SHans Petter Selasky 91*49901133SHans Petter Selasky /* Control and Status Header */ 92*49901133SHans Petter Selasky struct usie_cns { 93*49901133SHans Petter Selasky uint16_t obj; /* object type */ 94*49901133SHans Petter Selasky #define USIE_CNS_OB_RSSI 0x1001 /* read RSSI */ 95*49901133SHans Petter Selasky #define USIE_CNS_OB_HW_DISABLE 0x1011 /* disable h/w */ 96*49901133SHans Petter Selasky #define USIE_CNS_OB_PW_SW 0x1071 /* power on/off */ 97*49901133SHans Petter Selasky #define USIE_CNS_OB_PROF_WRITE 0x7003 /* write profile */ 98*49901133SHans Petter Selasky #define USIE_CNS_OB_LINK_UPDATE 0x7004 /* dis/connect */ 99*49901133SHans Petter Selasky #define USIE_CNS_OB_PDP_READ 0x7006 /* read out IP addr */ 100*49901133SHans Petter Selasky 101*49901133SHans Petter Selasky uint8_t op; /* operation type */ 102*49901133SHans Petter Selasky #define USIE_CNS_OP_ERR (1 << 7)/* | == error */ 103*49901133SHans Petter Selasky #define USIE_CNS_OP_REQ 0x01 /* host -> modem */ 104*49901133SHans Petter Selasky #define USIE_CNS_OP_RSP 0x02 /* h <- m */ 105*49901133SHans Petter Selasky #define USIE_CNS_OP_SET 0x03 /* h -> m */ 106*49901133SHans Petter Selasky #define USIE_CNS_OP_ACK 0x04 /* h <- m */ 107*49901133SHans Petter Selasky #define USIE_CNS_OP_NOTIF_ON 0x05 /* h -> m */ 108*49901133SHans Petter Selasky #define USIE_CNS_OP_RSP_ON 0x06 /* h <- m */ 109*49901133SHans Petter Selasky #define USIE_CNS_OP_NOTIF 0x07 /* h <- m */ 110*49901133SHans Petter Selasky #define USIE_CNS_OP_NOTIF_OFF 0x08 /* h -> m */ 111*49901133SHans Petter Selasky #define USIE_CNS_OP_RSP_OFF 0x09 /* h <- m */ 112*49901133SHans Petter Selasky #define USIE_CNS_OP_REQ_CHG 0x0a /* h -> m */ 113*49901133SHans Petter Selasky #define USIE_CNS_OP_RSP_CHG 0x0b /* h <- m */ 114*49901133SHans Petter Selasky 115*49901133SHans Petter Selasky uint8_t rsv0; /* reserved, always '0' */ 116*49901133SHans Petter Selasky uint32_t id; /* caller ID */ 117*49901133SHans Petter Selasky /* 118*49901133SHans Petter Selasky * .id is to identify calling functions 119*49901133SHans Petter Selasky * h/w responses with the same .id used in request. Only '0' is reserved 120*49901133SHans Petter Selasky * for notification (asynchronous message generated by h/w without any 121*49901133SHans Petter Selasky * request). All other values are user defineable. 122*49901133SHans Petter Selasky */ 123*49901133SHans Petter Selasky #define USIE_CNS_ID_NOTIF 0x00000000 /* reserved */ 124*49901133SHans Petter Selasky #define USIE_CNS_ID_INIT 0x00000001 125*49901133SHans Petter Selasky #define USIE_CNS_ID_STOP 0x00000002 126*49901133SHans Petter Selasky #define USIE_CNS_ID_DNS 0x00000003 127*49901133SHans Petter Selasky #define USIE_CNS_ID_RSSI 0x00000004 128*49901133SHans Petter Selasky 129*49901133SHans Petter Selasky uint8_t rsv1; /* reserved, always '0' */ 130*49901133SHans Petter Selasky uint8_t len; /* length of param */ 131*49901133SHans Petter Selasky } __packed; 132*49901133SHans Petter Selasky 133*49901133SHans Petter Selasky /* 134*49901133SHans Petter Selasky * CnS param attached to struct usie_cns 135*49901133SHans Petter Selasky * usie_cns.len is total size of this param 136*49901133SHans Petter Selasky * max 255 137*49901133SHans Petter Selasky */ 138*49901133SHans Petter Selasky #define USIE_CNS_PM_UP 0x01 139*49901133SHans Petter Selasky #define USIE_CNS_PM_DOWN 0x00 140*49901133SHans Petter Selasky 141*49901133SHans Petter Selasky /* Link Sense Indication data structure */ 142*49901133SHans Petter Selasky struct usie_lsi { 143*49901133SHans Petter Selasky uint8_t proto; 144*49901133SHans Petter Selasky #define USIE_LSI_UMTS 0x01 145*49901133SHans Petter Selasky 146*49901133SHans Petter Selasky uint8_t pad0; 147*49901133SHans Petter Selasky uint16_t len; 148*49901133SHans Petter Selasky uint8_t area; 149*49901133SHans Petter Selasky #define USIE_LSI_AREA_NO 0x00 150*49901133SHans Petter Selasky #define USIE_LSI_AREA_NODATA 0x01 151*49901133SHans Petter Selasky 152*49901133SHans Petter Selasky uint8_t pad1[41]; 153*49901133SHans Petter Selasky uint8_t state; 154*49901133SHans Petter Selasky #define USIE_LSI_STATE_IDLE 0x00 155*49901133SHans Petter Selasky 156*49901133SHans Petter Selasky uint8_t pad2[33]; 157*49901133SHans Petter Selasky uint8_t type; 158*49901133SHans Petter Selasky #define USIE_LSI_IP4 0x00 159*49901133SHans Petter Selasky 160*49901133SHans Petter Selasky uint8_t pdp_addr_len; /* PDP addr */ 161*49901133SHans Petter Selasky uint8_t pdp_addr[16]; 162*49901133SHans Petter Selasky uint8_t pad3[23]; 163*49901133SHans Petter Selasky uint8_t dns1_addr_len; /* DNS addr */ 164*49901133SHans Petter Selasky uint8_t dns1_addr[16]; 165*49901133SHans Petter Selasky uint8_t dns2_addr_len; 166*49901133SHans Petter Selasky uint8_t dns2_addr[16]; 167*49901133SHans Petter Selasky uint8_t wins1_addr_len; /* Wins addr */ 168*49901133SHans Petter Selasky uint8_t wins1_addr[16]; 169*49901133SHans Petter Selasky uint8_t wins2_addr_len; 170*49901133SHans Petter Selasky uint8_t wins2_addr[16]; 171*49901133SHans Petter Selasky uint8_t pad4[4]; 172*49901133SHans Petter Selasky uint8_t gw_addr_len; /* GW addr */ 173*49901133SHans Petter Selasky uint8_t gw_addr[16]; 174*49901133SHans Petter Selasky uint8_t rsv[8]; 175*49901133SHans Petter Selasky } __packed; 176*49901133SHans Petter Selasky 177*49901133SHans Petter Selasky struct usie_net_info { 178*49901133SHans Petter Selasky uint8_t addr_len; 179*49901133SHans Petter Selasky uint8_t pdp_addr[16]; 180*49901133SHans Petter Selasky uint8_t dns1_addr[16]; 181*49901133SHans Petter Selasky uint8_t dns2_addr[16]; 182*49901133SHans Petter Selasky uint8_t gw_addr[16]; 183*49901133SHans Petter Selasky } __packed; 184*49901133SHans Petter Selasky 185*49901133SHans Petter Selasky /* Tx/Rx IP packet descriptor */ 186*49901133SHans Petter Selasky struct usie_desc { 187*49901133SHans Petter Selasky struct usie_hip hip; 188*49901133SHans Petter Selasky uint16_t desc_type; 189*49901133SHans Petter Selasky #define USIE_TYPE_MASK 0x03ff 190*49901133SHans Petter Selasky #define USIE_IP_TX 0x0002 191*49901133SHans Petter Selasky #define USIE_IP_RX 0x0202 192*49901133SHans Petter Selasky 193*49901133SHans Petter Selasky struct ether_header ethhdr; 194*49901133SHans Petter Selasky } __packed; 195*49901133SHans Petter Selasky 196*49901133SHans Petter Selasky enum { 197*49901133SHans Petter Selasky USIE_UC_STATUS, 198*49901133SHans Petter Selasky USIE_UC_RX, 199*49901133SHans Petter Selasky USIE_UC_TX, 200*49901133SHans Petter Selasky USIE_UC_N_XFER 201*49901133SHans Petter Selasky }; 202*49901133SHans Petter Selasky 203*49901133SHans Petter Selasky enum { 204*49901133SHans Petter Selasky USIE_IF_STATUS, 205*49901133SHans Petter Selasky USIE_IF_RX, 206*49901133SHans Petter Selasky USIE_IF_TX, 207*49901133SHans Petter Selasky USIE_IF_N_XFER 208*49901133SHans Petter Selasky }; 209*49901133SHans Petter Selasky 210*49901133SHans Petter Selasky struct usie_softc { 211*49901133SHans Petter Selasky struct ucom_super_softc sc_super_ucom; 212*49901133SHans Petter Selasky 213*49901133SHans Petter Selasky #define USIE_UCOM_MAX 6 214*49901133SHans Petter Selasky struct ucom_softc sc_ucom[USIE_UCOM_MAX]; 215*49901133SHans Petter Selasky uint8_t sc_uc_ifnum[USIE_UCOM_MAX]; 216*49901133SHans Petter Selasky 217*49901133SHans Petter Selasky struct mtx sc_mtx; 218*49901133SHans Petter Selasky 219*49901133SHans Petter Selasky struct task sc_if_status_task; 220*49901133SHans Petter Selasky struct task sc_if_sync_task; 221*49901133SHans Petter Selasky struct usb_callout sc_if_sync_ch; 222*49901133SHans Petter Selasky 223*49901133SHans Petter Selasky struct usie_net_info sc_net; 224*49901133SHans Petter Selasky 225*49901133SHans Petter Selasky struct usie_desc sc_txd; 226*49901133SHans Petter Selasky 227*49901133SHans Petter Selasky struct usb_xfer *sc_uc_xfer[USIE_UCOM_MAX][USIE_UC_N_XFER]; 228*49901133SHans Petter Selasky struct usb_xfer *sc_if_xfer[USIE_IF_N_XFER]; 229*49901133SHans Petter Selasky 230*49901133SHans Petter Selasky struct ifnet *sc_ifp; 231*49901133SHans Petter Selasky struct usb_device *sc_udev; 232*49901133SHans Petter Selasky device_t sc_dev; 233*49901133SHans Petter Selasky 234*49901133SHans Petter Selasky struct mbuf *sc_rxm; 235*49901133SHans Petter Selasky 236*49901133SHans Petter Selasky uint16_t sc_if_ifnum; 237*49901133SHans Petter Selasky 238*49901133SHans Petter Selasky int16_t sc_rssi; 239*49901133SHans Petter Selasky 240*49901133SHans Petter Selasky uint8_t sc_msr; 241*49901133SHans Petter Selasky uint8_t sc_lsr; 242*49901133SHans Petter Selasky uint8_t sc_nucom; 243*49901133SHans Petter Selasky 244*49901133SHans Petter Selasky uint8_t sc_resp_temp[USIE_BUFSIZE] __aligned(4); 245*49901133SHans Petter Selasky uint8_t sc_status_temp[USIE_BUFSIZE] __aligned(4); 246*49901133SHans Petter Selasky }; 247*49901133SHans Petter Selasky 248*49901133SHans Petter Selasky /* Some code assumptions */ 249*49901133SHans Petter Selasky 250*49901133SHans Petter Selasky extern uint8_t usie_assert[((sizeof(struct usie_hip) + 251*49901133SHans Petter Selasky sizeof(struct usie_lsi) + 1) <= USIE_BUFSIZE) ? 1 : -1]; 252*49901133SHans Petter Selasky 253*49901133SHans Petter Selasky extern uint8_t ucdc_assert[(sizeof(struct usb_cdc_notification) 254*49901133SHans Petter Selasky >= 16) ? 1 : -1]; 255*49901133SHans Petter Selasky 256*49901133SHans Petter Selasky #endif /* _IF_USEVAR_H_ */ 257