From owner-freebsd-wireless@FreeBSD.ORG Sun Sep 25 00:59:03 2011 Return-Path: Delivered-To: freebsd-wireless@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8048B106566C; Sun, 25 Sep 2011 00:59:03 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2D3F68FC08; Sun, 25 Sep 2011 00:59:02 +0000 (UTC) Received: by ywp17 with SMTP id 17so4483453ywp.13 for ; Sat, 24 Sep 2011 17:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=adBXbPf4YBo3TmbTd5fDrk4HZb+xQNwUlJ1oNw8q+Ag=; b=JNuDRjPLfa9m3tkI1wJf8bJ/8xjLGJNHm8ManZVR7Vh/nXbPwcPwWpSBqKB+Z6aEGH SxnW+xel2gDVxFwDiAPxAmTFFWrkQ/RAKbFfWzisDbdnlnngRvtD6cHB2/AlfWyPcoO0 8jSxgAcfCMSt+5dSOCW+h25xR2ftPSGFUakfM= MIME-Version: 1.0 Received: by 10.236.124.97 with SMTP id w61mr30593486yhh.106.1316912342295; Sat, 24 Sep 2011 17:59:02 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.236.111.42 with HTTP; Sat, 24 Sep 2011 17:59:02 -0700 (PDT) In-Reply-To: <9CA9DCD5-2B81-443D-BAC9-1B5D9E703B15@alumni.cwru.edu> References: <9CA9DCD5-2B81-443D-BAC9-1B5D9E703B15@alumni.cwru.edu> Date: Sun, 25 Sep 2011 08:59:02 +0800 X-Google-Sender-Auth: Qk7WPGGUHCRbXgHLJS1zjPfS4mQ Message-ID: From: Adrian Chadd To: Justin Hibbits Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-wireless@freebsd.org, FreeBSD PowerPC ML Subject: Re: if_wi attachment for mac-io X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Sep 2011 00:59:03 -0000 On 24 September 2011 23:14, Justin Hibbits wrote: > pci2:0:14:0: reprobing on driver added > wi0: mem 0x30000-0x300ff,0x1a000-0x1a0ff,0-0xff irq 57 on > macio0 > wi0: record read mismatch, rid=fd0b, got=bfd > wi0: using Unknown Lucent chip > wi0: record read mismatch, rid=fd20, got=20fd > wi0: Hermes Firmware: Station (0.0.0) > wi0: Sorry, this card is not supported (type 1, firmware ver 0) > device_attach: wi0 attach returned 45 > > > Is there a way to add a shim underneath the driver, or something else so as > not to be too intrusive to the if_wi driver? Hm, it looks like there's explicit casts to/from little endian in wi_read_rid() and wi_write_rid(). The bus read/write value swapping are already handled for you by the bus glue. What's left are the contents of buffers. I guess read/write_rid are using struct wi_lt_hdr implicitly without actually using the struct. * One form of communication with the Hermes is with what Lucent calls * LTV records, where LTV stands for Length, Type and Value. The length * and type are 16 bits and are in native byte order. The value is in * multiples of 16 bits and is in little endian byte order. If you look at wi_read_bap() and wi_write_bap(), they treat the buffer as a set of 16 bit words being read from WI_DATA0. I'd expect the CSR_READ_2() define to correctly swap the data from device to host order. I wonder about the correct endian-ness of the buffer read - ie, the bus space macro is turning it into a 16 bit host-endian data read. Ie, your PPC is in Big-endian mode, so the le16toh() macro isn't a NULL. I don't know why Bill used le16toh() here, if the length/value fields from the NIC are supposed to be host-order. I suggest just removing the le16toh() and htole16() calls in wi_read_rid() and wi_write_rid() as again these may be host-endian data. Code which calls wi_read_rid() and wi_read_bap() seem to do some explicit endian conversions of data fields but I bet there may be missing ones lurking here and there. So fixing up wi_read_rid() and wi_write_rid() may make probe/attach function, but you may find weird crap occuring. :-) Give that a shot, then look at the openbsd/netbsd wi driver to see if they've investigated and fixed endian issues. :) Adrian