NIC irq nobody cared ? virtual to physical and DMA questions

2005-11-29 Thread Mateusz Berezecki
Hello List,

This time the questions are different.

Given the following output could anyone please tell me what is wrong ?
In explicit what does that mysterious nobody cared message mean?
And another stupid question: should DMA for a network card be enabled before or 
maybe
_after_ interrupts get enabled? And... how to convert virtual address
to physical one?

Nov 29 21:25:47 debian kernel: atheros: receive init routine called
Nov 29 21:25:47 debian kernel: atheros: physical address of RX head is 
Nov 29 21:25:47 debian kernel: atheros: enabling DMA receive. this can crash 
things supposedly.
Nov 29 21:25:47 debian kernel: irq 11: nobody cared (try booting with the 
irqpoll option)
Nov 29 21:25:47 debian kernel:  [dump_stack+23/32] dump_stack+0x17/0x20
Nov 29 21:25:47 debian kernel:  [__report_bad_irq+39/144] 
__report_bad_irq+0x27/0x90
Nov 29 21:25:47 debian kernel:  [note_interrupt+114/192] 
note_interrupt+0x72/0xc0
Nov 29 21:25:47 debian kernel:  [__do_IRQ+200/224] __do_IRQ+0xc8/0xe0
Nov 29 21:25:47 debian kernel:  [do_IRQ+80/128] do_IRQ+0x50/0x80
Nov 29 21:25:47 debian kernel:  ===
Nov 29 21:25:47 debian kernel:  [common_interrupt+26/32] 
common_interrupt+0x1a/0x20
Nov 29 21:25:47 debian kernel:  [do_softirq+115/128] do_softirq+0x73/0x80
Nov 29 21:25:47 debian kernel:  ===
Nov 29 21:25:47 debian kernel:  [irq_exit+67/80] irq_exit+0x43/0x50
Nov 29 21:25:47 debian kernel:  [do_IRQ+87/128] do_IRQ+0x57/0x80
Nov 29 21:25:47 debian kernel:  [common_interrupt+26/32] 
common_interrupt+0x1a/0x20
Nov 29 21:25:47 debian kernel:  [pg0+260065664/1065075712] ath_init+0x30/0x80 
[atheros]
Nov 29 21:25:47 debian kernel:  [dev_open+70/144] dev_open+0x46/0x90
Nov 29 21:25:47 debian kernel:  [dev_change_flags+83/288] 
dev_change_flags+0x53/0x120
Nov 29 21:25:47 debian kernel:  [devinet_ioctl+1437/1472] 
devinet_ioctl+0x59d/0x5c0
Nov 29 21:25:47 debian kernel:  [inet_ioctl+166/208] inet_ioctl+0xa6/0xd0
Nov 29 21:25:47 debian kernel:  [sock_ioctl+248/592] sock_ioctl+0xf8/0x250
Nov 29 21:25:47 debian kernel:  [do_ioctl+40/144] do_ioctl+0x28/0x90
Nov 29 21:25:47 debian kernel:  [vfs_ioctl+87/496] vfs_ioctl+0x57/0x1f0
Nov 29 21:25:47 debian kernel:  [sys_ioctl+57/96] sys_ioctl+0x39/0x60
Nov 29 21:25:47 debian kernel:  [syscall_call+7/11] syscall_call+0x7/0xb
Nov 29 21:25:47 debian kernel: handlers:
Nov 29 21:25:47 debian kernel: [usb_hcd_irq+0/80] (usb_hcd_irq+0x0/0x50)
Nov 29 21:25:47 debian last message repeated 3 times
Nov 29 21:25:47 debian kernel: [yenta_interrupt+0/192] 
(yenta_interrupt+0x0/0xc0)
Nov 29 21:25:47 debian kernel: [pg0+260075488/1065075712] (ath_intr+0x0/0x150 
[atheros])
Nov 29 21:25:47 debian kernel: Disabling IRQ #11
Nov 29 21:25:47 debian kernel: atheros: interrupts enabled
Nov 29 21:25:47 debian kernel: atheros: device up and running

-- 
kind regards,
 Mateusz Berezecki

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re[2]: net_device + pci_dev question

2005-11-28 Thread Mateusz Berezecki
Hello Arjan,

On 27th november 2005 (22:25:13) you wrote:

 On Sun, 2005-11-27 at 20:58 +0100, Mateusz Berezecki wrote:
 Hello List!
 
 Having only net_device pointer is it possible to retrieve associated pci_dev
 pointer basing on this information only?

 what do you need it for?

for pci_alloc_consistent() which takes pci_dev as a first argument to
allocate contiguous memory block for DMA transfers. I just realized
when I saw your answer that I might have moved the memory allocation to
some routine which is called earlier in time which has access to
pci_dev pointer directly, like net_device-init IIRC. But I'm not
really sure if that would be correct solution.

 (and.. what if the nic isn't a pci one?)

Uh... it's cardbus interface and still uses pci_* stuff without problems. (?)
Do I miss something?

kind regards
Mateusz Berezecki

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re[4]: net_device + pci_dev question

2005-11-28 Thread Mateusz Berezecki
Hello Arjan,

On 28th november 2005 (22:03:38) you wrote:

 oh it's *your own* netdev...

Yes:-) Sorry for not being precise

 that makes things a lot easier ;)


 it's custom to have driver private data per net dev
 (see netdev_priv() to get it, alloc_etherdev() takes the size of it as
 argument). It's custom to make that private data a struct in which you
 can store the pci device pointer yourself, as well as any other per card
 data that you need to store


Ok, I will do it like that then. Thank you for the explanation on this
issue.

kind regards,
Mateusz Berezecki

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


memory allocation for DMA operations from network interface

2005-11-27 Thread Mateusz Berezecki
Hello List,

My question is about DMA transfers from network device. I suspect
these transfers require allocating physically contiguous memory 
blocks. What is the proper way to allocate such contiguous memory for
DMA purposes inside the kernel? Also what is the proper and
architecture independent way to convert virtual address to physical
one?


kind regards
Mateusz Berezecki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: atheros driver - desc

2005-08-06 Thread Mateusz Berezecki
Kalle Valo [EMAIL PROTECTED] wrote:
| 
| This is great news. An open source Atheros driver which could be
| included to Linux is really needed.
| 
| But how was the reverse engineering done? I noticed that forcedeth
| driver was implemented using the clean room design[1] and Linux
| Broadcom 4301 driver project[2] seems to be using the same method.

  Reverse engineering was done by dissassemblying binary HAL
  and in harder parts by running it in userspace(yes, that is possible)
  and analysing input and produced output. The crucial part was to
  discover the meaning of hidden part of the structure describing
  device state. Once this was done it will be a little if no problem to me
  to provide updates for this driver, unless the whole binary HAL
  changes dramatically. That's one of the reasons I do this work myself.
  
| 
| The reason I'm asking this is that I just wouldn't want see the same
| happening this with this driver as happened during reverse engineering
| of pwc Philips Webcam driver (some parts of the driver were removed
| from kernel, but I believe the situation is now solved).

  If get into trouble I write documentation :-) I promise.


| Actually, what are requirements to get a reverse engineered driver
| included to Linux? Is clean room design an absolute must? It seems
| that reverse engineering is needed if we want Linux support for most
| of the WLAN cards on the market :(
| 

   Sad but true. The problem is not at vendors' side though.
   Look at FCC regulations... :/


   kind regards
   Mateusz


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 4/8] atheros driver - eeprom routines

2005-08-05 Thread Mateusz Berezecki
resending patch 4/8 as it was reported missing
diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' 
netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/eeprom.c 
netdev-atheros/drivers/net/wireless/atheros/atheros5212/eeprom.c
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/eeprom.c  
1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/eeprom.c
2005-08-05 03:48:36.0 +0200
@@ -0,0 +1,501 @@
+/*
+ * All the work was created by reverse engineering and porting
+ * for interoperability. The creator is Mateusz Berezecki,
+ * unless explicitly marked ( some parts are derived
+ * from GPL'ed parts of madwifi project located at http://madwifi.sf.net)
+ *
+ * the original assembly code has been created by Sam Leffler
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ * 
+ * rest of the code has been reversed by me and is under copyright too
+ * Copyright (C) 2005  Mateusz Berezecki
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA.
+ *
+ */
+
+#include linux/config.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/version.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pci.h
+#include linux/netdevice.h
+
+#include net/ieee80211.h
+
+#include linux/wireless.h
+#include net/iw_handler.h
+
+#include atheros_id.h
+#include atheros_dev.h
+#include atheros_defs.h
+//#include atheros_devops.h
+//#include atheros_regops.h
+#include atheros_registers.h
+#include atheros.h
+#include eeprom.h
+
+/* XXX add calibration info */
+unsigned int get_cal(struct eeprom_info *e, unsigned int val)
+{
+   return 0;
+}
+
+
+/* should be called poll_read. waits some time for a specific value
+ * being read */
+unsigned int ath_timed_read(struct net_device *netdev,
+   unsigned int reg, unsigned int mask,
+   unsigned int val)
+{
+   unsigned int i, tmp;
+   for (i = 0; i  1000; i++) {
+   tmp = ath_reg_read(netdev, reg)  mask;
+   if ((tmp  mask) == val)
+   return 1;
+   udelay(15);
+   }
+   
+   printk(KERN_DEBUGatheros: timed read failing: mask:%x val:%x\n,
+   mask, val);
+   return 0;
+}
+
+/* read from EEPROM */
+unsigned int eeprom_read(struct net_device *netdev, 
+   unsigned int x, unsigned int *val)
+{
+   
+   ath_reg_write(netdev, 0x6000, x);
+   ath_reg_write(netdev, 0x6008, 1);
+
+   if (!ath_timed_read(netdev, 0x600c, 3, 2))
+   return 0;
+
+   *val = ath_reg_read(netdev, 0x6004)  0x;
+   
+   return 1;   
+}
+
+/* read antenna control stuff while initializing the chipset */
+void eeprom_read_ant_control(struct net_device *netdev, unsigned int reg, 
unsigned int idx)
+{
+   struct atheros_priv *pdata = ieee80211_priv(netdev);
+   struct eeprom_info *e = pdata-eeinfo;
+   unsigned int val;
+   
+   eeprom_read(netdev, reg++, val);
+   e-switchval[idx] = (val  8)  0x7f;
+   e-txrx[idx] = (val  2)  0x3f;
+
+   e-antctrl[0][idx] = (val  4)  0x3f;
+   e-antctrl[0][idx] |= (val  12)  0x0f;
+   e-antctrl[1][idx] = (val  6)  0x3f;
+   e-antctrl[2][idx] = val  0x3f;
+
+   eeprom_read(netdev, reg++, val);
+   e-antctrl[3][idx] = (val  10)  0x3f;
+   e-antctrl[4][idx] = (val  4)  0x3f;
+   e-antctrl[5][idx] = (val  2)  0x3f;
+
+   eeprom_read(netdev, reg++, val);
+   e-antctrl[5][idx] |= (val  14)  3;
+   e-antctrl[6][idx] = (val  8)  0x3f;
+   e-antctrl[7][idx] = (val  2)  0x3f;
+   e-antctrl[8][idx] = (val  4)  0x3f;
+
+   eeprom_read(netdev, reg++, val);
+   e-antctrl[8][idx] |= (val  12)  0xf;
+   e-antctrl[9][idx] = (val  6)  0x3f;
+   e-antctrl[10][idx] = val  0x3f;
+
+   
+}
+
+/* read wireless mode info from EEPROM 
+ * XXX: this needs splitting to be more readable.
+ * though i have no idea how to do it yet
+ *
+ * this is UGLY UGLY UGLY
+ */
+void eeprom_read_mode(struct net_device *netdev, unsigned int reg, int k)
+{
+   struct atheros_priv *pdata = ieee80211_priv(netdev);
+   struct eeprom_info *e = pdata-eeinfo;
+   unsigned int val;
+   
+   eeprom_read_ant_control(netdev, reg

atheros driver - desc

2005-08-04 Thread Mateusz Berezecki

Hi list members,

I just post the code for review for anyone interested.
I would be more than pleased to hear some feedback from you on the code.

Im sending a series of 8 patches splitted and diffed as in 
SubmittingPatches documentation.


The driver is not yet fully working because I didn't finish kernel 
integration yet. Almost all
driver I/O ops are reverse engineered independently of openbsd openhal 
which is missing just too much.



Ok, enough talking. Most of the atheros 5212 hal is now open :)

sending patches...

Mateusz

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


atheros driver (1/8)

2005-08-04 Thread Mateusz Berezecki


--- netdev-2.6.git#ieee80211/drivers/net/wireless/Kconfig	2005-08-02 13:18:21.0 +0200
+++ netdev-atheros/drivers/net/wireless/Kconfig	2005-08-05 03:43:32.0 +0200
@@ -459,6 +459,14 @@ config PRISM54
 	  say M here and read file:Documentation/modules.txt.  The module
 	  will be called prism54.ko.
 
+comment Atheros combo cardbus cards support
+config PCMCIA_ATHEROS_5212
+	tristate Atheros 5212 (a/b/g) combo cards
+	depends on NET_RADIO  EXPERIMENTAL  PCMCIA
+	---help---
+	  Experimental support for Atheros radio chips.
+
+	
 # yes, this works even when no drivers are selected
 config NET_WIRELESS
 	bool
diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/Makefile netdev-atheros/drivers/net/wireless/Makefile
--- netdev-2.6.git#ieee80211/drivers/net/wireless/Makefile	2005-08-02 13:18:22.0 +0200
+++ netdev-atheros/drivers/net/wireless/Makefile	2005-08-05 03:48:17.0 +0200
@@ -35,3 +35,5 @@ obj-$(CONFIG_PRISM54)		+= prism54/
 # 16-bit wireless PCMCIA client drivers
 obj-$(CONFIG_PCMCIA_RAYCS)	+= ray_cs.o
 obj-$(CONFIG_PCMCIA_WL3501)	+= wl3501_cs.o
+
+obj-$(CONFIG_PCMCIA_ATHEROS_5212) += atheros/atheros5212/
diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/Makefile netdev-atheros/drivers/net/wireless/atheros/atheros5212/Makefile
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/Makefile	1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/Makefile	2005-08-05 03:51:53.0 +0200
@@ -0,0 +1,3 @@
+atheros5212-objs := init.o eeprom.o beacons.o powermodes.o keys.o mode_tables.o regops.o interrupts.o caps.o chans.o transmit_receive.o mode_tables.o other.o ioctl.o
+
+obj-$(CONFIG_PCMCIA_ATHEROS_5212) += atheros5212.o



atheros driver (3/8)

2005-08-04 Thread Mateusz Berezecki


diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/beacons.c netdev-atheros/drivers/net/wireless/atheros/atheros5212/beacons.c
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/beacons.c	1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/beacons.c	2005-08-05 03:48:36.0 +0200
@@ -0,0 +1,235 @@
+/*
+ * All the work was created by reverse engineering and porting
+ * for interoperability. The creator is Mateusz Berezecki,
+ * unless explicitly marked ( some parts are derived
+ * from GPL'ed parts of madwifi project located at http://madwifi.sf.net)
+ *
+ * derived or copied parts of code licensed under
+ * dual GPL/BSD license
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ * 
+ * rest of the code has been reversed by me and is under copyright too
+ * Copyright (C) 2005  Mateusz Berezecki
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include linux/config.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/version.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pci.h
+#include linux/netdevice.h
+
+#include net/ieee80211.h
+
+#include linux/wireless.h
+#include net/iw_handler.h
+
+#include atheros_id.h
+#include atheros_dev.h
+#include atheros_defs.h
+//#include atheros_devops.h
+//#include atheros_regops.h
+#include atheros_registers.h
+#include atheros.h
+
+
+
+
+void ath_beacon_init(struct net_device *netdev, unsigned int nextbtt,
+		unsigned int intval)
+{
+	struct atheros_priv *pdata = ieee80211_priv(netdev);
+	struct ieee80211_device *dev = netdev_priv(netdev);
+	unsigned int val;
+	
+	ath_reg_write(netdev, AR5212_TIMER0, nextbtt);
+
+	switch (dev-iw_mode) {
+		case IW_MODE_MONITOR:
+		case IW_MODE_INFRA:
+			ath_reg_write(netdev,
+AR5212_TIMER1,
+0x);
+			ath_reg_write(netdev,
+AR5212_TIMER2, 
+0x7); 
+			break;
+			
+		case IW_MODE_ADHOC:
+			ath_reg_write(netdev,
+AR5212_TIMER1, 
+(nextbtt - 2)  3);
+			ath_reg_write(netdev,
+AR5212_TIMER2,
+(nextbtt - 10)  3);
+			break;
+			
+		default:
+			break;
+	}
+
+	ath_reg_write(netdev, AR5212_TIMER3, nextbtt + 
+		  (pdata-atim_win ? pdata-atim_win : 1));
+	
+	val = intval  
+		(AR5212_BEACON_PERIOD | 
+		 AR5212_BEACON_RESET_TSF |
+		 AR5212_BEACON_ENABLE);
+	
+	if (val  AR5212_BEACON_RESET_TSF)
+		ath_reg_write(netdev, AR5212_BEACON, 
+AR5212_BEACON_RESET_TSF); 
+	
+	ath_reg_write(netdev, AR5212_BEACON, val);
+}
+
+void ath_reset_station_btimers(struct net_device *netdev)
+{
+	int tmp;
+
+	ath_reg_write(netdev, AR5212_TIMER0, 0);
+	tmp = (ath_reg_read(netdev, AR5212_STA_ID1) 
+			| AR5212_STA_ID1_PWR_SV)  
+			~(AR5212_STA_ID1_DEFAULT_ANTENNA |
+			AR5212_STA_ID1_PCF); 
+	
+	
+	ath_reg_write(netdev, AR5212_BEACON, 0x);
+	return;
+}
+
+void ath_set_station_btimers(struct net_device *netdev, 
+		struct beacon_state *state, unsigned int tsf,
+		unsigned int dtcx, unsigned int cfpcx)
+{
+	unsigned int tmp, dtimp, nextt;
+	unsigned int bintval;
+	
+	if (state-bs_cfpperiod) {
+		tmp = ath_reg_read(netdev, AR5212_STA_ID1);
+		tmp |= AR5212_STA_ID1_PCF;
+		
+		ath_reg_write(netdev, AR5212_STA_ID1, tmp);
+		
+		ath_reg_write(netdev, AR5212_CFP_PERIOD, 
+state-bs_cfpperiod *
+state-bs_dtimperiod * 
+state-bs_intval);
+		
+		ath_reg_write(netdev, AR5212_CFP_DUR, 
+state-bs_cfpmaxduration);
+		
+		ath_reg_write(netdev, AR5212_TIMER2, 
+			((tsf + 
+			((cfpcx * state-bs_dtimperiod + dtcx) *
+			 state-bs_intval)))  3);
+	} else 
+		ath_reg_disable(netdev, 
+			AR5212_STA_ID1,
+			AR5212_STA_ID1_PCF);
+
+	
+	bintval = state-bs_intval;
+	
+	ath_reg_write(netdev, AR5212_TIMER0, state-bs_nexttbtt);
+
+	tmp = ath_reg_read(netdev, AR5212_BEACON)  0xff80;
+	tmp |= state-bs_intval  0x;
+
+	if (state-bs_timoffset) {
+		tmp |= ((state-bs_timoffset + 4)  16)  0x7f;
+	} else {
+		tmp |= (4  16)  0x7f;
+	}
+
+	ath_reg_write(netdev, AR5212_BEACON, tmp);
+
+	
+	if (state-bs_bmissthreshold = (0xff00  8)) {
+		BUG();
+		return;
+	}
+
+	tmp = ath_reg_read(netdev, AR5212_RSSI_THR)  (~0xff00);
+	tmp |= (state-bs_bmissthreshold  8)  0xff00;
+	ath_reg_write(netdev, AR5212_RSSI_THR, tmp

atheros driver (5/8)

2005-08-04 Thread Mateusz Berezecki


diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/init.c netdev-atheros/drivers/net/wireless/atheros/atheros5212/init.c
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/init.c	1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/init.c	2005-08-05 03:48:36.0 +0200
@@ -0,0 +1,788 @@
+/*
+ * All the work was created by reverse engineering and porting
+ * for interoperability. The creator is Mateusz Berezecki,
+ * unless explicitly marked ( some parts are derived
+ * from GPL'ed parts of madwifi project located at http://madwifi.sf.net)
+ *
+ * derived or copied parts of code licensed under
+ * dual GPL/BSD license
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ * 
+ * rest of the code has been reversed by me are under copyright too... should they?:P
+ * Copyright (C) 2005  Mateusz Berezecki
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include linux/config.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/version.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pci.h
+#include linux/netdevice.h
+
+#include net/ieee80211.h
+
+#include linux/wireless.h
+#include net/iw_handler.h
+
+#include atheros_id.h
+#include atheros_dev.h
+#include atheros_defs.h
+#include atheros_registers.h
+#include atheros.h
+#include eeprom.h
+#include interrupts.h
+#include regops.h
+#include powermodes.h
+#include transmit_receive.h
+#include chans.h
+
+struct net_device *atheros_card = NULL;
+
+unsigned int ath_radio(struct net_device *netdev)
+{
+	unsigned int ret = 0,val = 0;
+	unsigned int i;
+	
+	ath_reg_write(netdev, 0x9800 + (0x34  2), 0x1c16);
+	
+	for (i = 0; i  8; i++)
+		ath_reg_write(netdev, 0x9800 + (0x20  2), 0x1);
+
+	val = ath_reg_read(netdev, 0x9800 + (256  2));
+	val = (val  24)  0xff;
+	val = (val  0xf0)  4;
+	val |= ((val  0x0f)  4);
+	
+	for (i = 0; i  8; i++) {
+		ret = (ret  1) | (val  1);
+		val = val  1;
+	}
+	
+	return ret;
+}
+
+unsigned int ath_selftest(struct net_device *netdev)
+{
+	unsigned int i, j;
+	unsigned int regs[2] = { 0x8000, 0x9800 + (8  2) };
+	unsigned int vals[2];
+	unsigned int values[4] = { 
+		0x, 0x,
+		0x, 0x 
+	};
+	
+	for (i = 0; i  2; i++) {
+		unsigned int addr = regs[i];
+		unsigned int wdata, rdata;
+		
+		vals[i] = ath_reg_read(netdev, addr);
+		
+		for (j = 0; j  256; j++) {
+			wdata = (j  16) | j;
+			ath_reg_write(netdev, addr, wdata);
+			rdata = ath_reg_read(netdev, addr);
+			if (wdata != rdata) {
+printk(KERN_DEBUGatheros:(%d) read %x exp. %x\n,
+	j, rdata, wdata);
+return 0;
+			}
+		}
+
+		for (j = 0; j  4; j++) {
+			unsigned int tmp;
+			ath_reg_write(netdev, regs[i], values[j]);
+			tmp = ath_reg_read(netdev, regs[i]);
+			if (values[j] != tmp) {
+printk(KERN_DEBUGatheros: 2nd loop\n);
+return 0;
+			}
+		}
+		ath_reg_write(netdev, regs[i], vals[i]);
+	}
+	udelay(100);
+	return 1;
+}
+
+unsigned int ath_set_reset_register(struct net_device *netdev, 
+unsigned int rmask)
+{
+	unsigned int mask = rmask ? rmask : ~0;
+	unsigned int t;
+	
+	
+	ath_reg_read(netdev, 0x000c);
+	ath_reg_write(netdev, 0x4000, rmask);
+	udelay(15);
+
+	mask = (0x0001 | 0x0002);
+	rmask = (0x0001 | 0x0002);
+	t = ath_timed_read(netdev, 0x4000, mask, rmask);
+	
+	if ((rmask  1) == 0) {
+		ath_reg_write(netdev, 0x14, 0);
+		if (!ath_set_power_mode(netdev, 2, 1, 0))
+			return t;
+		ath_reg_read(netdev, 0xc0);
+	}
+	return t;
+}
+
+unsigned int ath_prep_reset(struct net_device *netdev)
+{
+	return 1;
+}
+
+unsigned int ath_chip_reset(struct net_device *netdev, void *unused)
+{
+	
+	if (!ath_set_reset_register(netdev, 0x13)) {
+		printk(KERN_DEBUGatheros: if 1 (warm reset)\n);
+		return 0;
+	}
+
+	if (!ath_set_power_mode(netdev, 2, 1, 0)) {
+		printk(KERN_DEBUGatheros: if #2 (power mode)\n);
+		return 0;
+	}
+
+	if (!ath_set_reset_register(netdev, 0)) {
+		printk(KERN_DEBUGatheros: if 3 (cold reset)\n);
+		return 0;
+	}
+
+	if (unused == NULL)
+		return 1;
+
+	return 0;
+}
+
+unsigned int ath_reset(struct net_device *netdev)
+{
+	return 0;
+}
+
+struct chip_gain_desc athgaindesc = {
+	.entrycnt = 9,
+	.defentry = 4

atheros driver (6/8)

2005-08-04 Thread Mateusz Berezecki


diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/ioctl.c netdev-atheros/drivers/net/wireless/atheros/atheros5212/ioctl.c
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/ioctl.c	1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/ioctl.c	2005-08-05 03:48:36.0 +0200
@@ -0,0 +1,590 @@
+/*
+ * All the work was created by reverse engineering and porting
+ * for interoperability. The creator is Mateusz Berezecki,
+ * unless explicitly marked ( some parts are derived
+ * from GPL'ed parts of madwifi project located at http://madwifi.sf.net)
+ *
+ * derived or copied parts of code licensed under
+ * dual GPL/BSD license
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ * 
+ * rest of the code has been reverse engineered by Mateusz Berezecki
+ * Copyright (C) 2005  Mateusz Berezecki
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include linux/config.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/version.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pci.h
+#include linux/netdevice.h
+
+#include net/iw_handler.h
+#include linux/wireless.h
+#include net/ieee80211.h
+
+#include atheros_id.h
+#include atheros_dev.h
+#include atheros_defs.h
+#include atheros_registers.h
+#include atheros.h
+#include eeprom.h
+#include interrupts.h
+#include regops.h
+#include powermodes.h
+#include transmit_receive.h
+#include chans.h
+
+
+/*
+ * These are just templates for future expansion. I would have done
+ * that already but unfortunately I have to get familiar with
+ * new ieee80211 API first... Help!!! ;-p
+ */
+
+int ath_ioctl_giwname(struct net_device *netdev, struct iw_request_info *info, 
+		char *name, char *extra)
+{
+	struct ieee80211_device *dev = netdev_priv(netdev);
+	
+	switch (dev-mode) {
+		case IEEE_A:
+			strncpy(name, IEEE 802.11a, IFNAMSIZ);
+			break;
+		case IEEE_B:
+			strncpy(name, IEEE 802.11b, IFNAMSIZ);
+			break;
+		case IEEE_G:
+			strncpy(name, IEEE 802.11b, IFNAMSIZ);
+			break;
+		default:
+			strncpy(name, IEEE 802.11, IFNAMSIZ);
+			break;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(ath_ioctl_giwname);
+
+int ath_ioctl_siwencode(struct net_device *netdev, 
+		struct iw_request_info *info,
+		struct iw_point *erq, char *extra)
+{
+	/* not yet supported */
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_siwencode);
+
+int ath_ioctl_giwencode(struct net_device *netdev, 
+		struct iw_request_info *info, 
+		struct iw_point *erq, char *extra)
+{
+	/* not yet supported */
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_giwencode);
+
+int ath_ioctl_siwrate(struct net_device *netdev, 
+		struct iw_request_info *info, 
+		struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_siwrate);
+
+int ath_ioctl_giwrate(struct net_device *netdev, struct iw_request_info *info, struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_giwrate);
+
+int ath_ioctl_siwsens(struct net_device *netdev, struct iw_request_info *info, struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_siwsens);
+
+int ath_ioctl_giwsens(struct net_device *netdev, struct iw_request_info *info, struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_giwsens);
+
+int ath_ioctl_siwrts(struct net_device *netdev, struct iw_request_info *info, struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_siwrts);
+
+int ath_ioctl_giwrts(struct net_device *netdev, struct iw_request_info *info, struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_giwrts);
+
+int ath_ioctl_siwfrag(struct net_device *netdev, struct iw_request_info *info, struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_siwfrag);
+
+int ath_ioctl_giwfrag(struct net_device *netdev, struct iw_request_info *info, struct iw_param *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_giwfrag);
+
+int ath_ioctl_siwap(struct net_device *netdev, struct iw_request_info *info, struct sockaddr *erq, char *extra)
+{
+	return -1;
+}
+EXPORT_SYMBOL(ath_ioctl_siwap);
+
+int ath_ioctl_giwap(struct net_device *netdev, struct iw_request_info

atheros driver (7/8)

2005-08-04 Thread Mateusz Berezecki


diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/keys.c netdev-atheros/drivers/net/wireless/atheros/atheros5212/keys.c
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/keys.c	1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/keys.c	2005-08-05 03:48:36.0 +0200
@@ -0,0 +1,268 @@
+/*
+ * All the work was created by reverse engineering and porting
+ * for interoperability. The creator is Mateusz Berezecki,
+ * unless explicitly marked ( some parts are derived
+ * from GPL'ed parts of madwifi project located at http://madwifi.sf.net)
+ *
+ * derived or copied parts of code licensed under
+ * dual GPL/BSD license
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ * 
+ * rest of the code has been reversed by me and is under copyright too
+ * Copyright (C) 2005  Mateusz Berezecki
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+#include linux/config.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/version.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pci.h
+#include linux/netdevice.h
+
+#include net/ieee80211.h
+
+#include linux/wireless.h
+#include net/iw_handler.h
+
+#include atheros_id.h
+#include atheros_dev.h
+#include atheros_defs.h
+//#include atheros_devops.h
+//#include atheros_regops.h
+#include atheros_registers.h
+#include atheros.h
+
+
+unsigned int ath_keycache_valid(struct net_device *netdev,
+		unsigned short entry)
+{
+	struct atheros_priv *pdata;
+	unsigned int val;
+	
+	pdata = ieee80211_priv(netdev);
+	
+	if (entry  pdata-max_keycache)
+		return 0;
+	
+	val = ath_reg_read(netdev, 0x8800 + entry * 32 + 28);
+
+	if (val  0x8000)
+		return 1;
+	
+	return 0;
+}
+
+unsigned int ath_reset_keycache(struct net_device *netdev,
+		unsigned short entry)
+{
+	struct atheros_priv *pdata;
+	unsigned int keytype;
+	
+	pdata = ieee80211_priv(netdev);
+	
+	if (entry  pdata-keycache_size)
+		return 0;
+
+	keytype = ath_reg_read(netdev, (entry * 32) + 0x8814);
+
+	ath_reg_write(netdev, (entry * 32) + 0x8800, 0);
+	ath_reg_write(netdev, (entry * 32) + 0x8804, 0);
+	ath_reg_write(netdev, (entry * 32) + 0x8808, 0);
+	ath_reg_write(netdev, (entry * 32) + 0x880c, 0);
+	ath_reg_write(netdev, (entry * 32) + 0x8810, 0);
+	ath_reg_write(netdev, (entry * 32) + 0x8814, 7);
+	ath_reg_write(netdev, (entry * 32) + 0x8818, 0);
+	ath_reg_write(netdev, (entry * 32) + 0x881c, 0);
+	
+	if (keytype != 4)
+		return 1;
+
+	if (!pdata-ext_keycache)
+		return 1;
+
+	ath_reg_write(netdev, ((entry + 64) * 32) + 0x8800, 0);
+	ath_reg_write(netdev, ((entry + 64) * 32) + 0x8804, 0);
+	ath_reg_write(netdev, ((entry + 64) * 32) + 0x8808, 0);
+	ath_reg_write(netdev, ((entry + 64) * 32) + 0x880c, 0);
+
+	return 1;
+}
+
+unsigned int ath_set_keycache_entry_mac(struct net_device *netdev,
+		unsigned short entry, unsigned char *mac)
+{
+	struct atheros_priv *pdata;
+	unsigned int mac1, mac2;
+	
+	pdata = ieee80211_priv(netdev);
+
+	if (entry  pdata-max_keycache)
+		return 0;
+
+	if (mac == NULL) {
+		mac1 = 0;
+		mac2 = 0;
+	} else {
+		mac1  = mac[5]  8;
+		mac1 |= mac[4];
+		
+		mac2  = mac[3]  24;
+		mac2 |= mac[2]  16;
+		mac2 |= mac[1]  8;
+		mac2 |= mac[0];
+		
+		mac2 = mac2  1;
+		mac2 |= ((mac1  1) 31);
+		
+		mac1 = mac1  1;
+	}
+
+	ath_reg_write(netdev, (entry * 32) + 0x8800 + 24, mac2);
+	ath_reg_write(netdev, (entry * 32) + 0x8800 + 28, mac1 | 0x80);
+
+	return 1;
+}
+
+unsigned int ath_set_keycache_entry(struct net_device *netdev,
+		unsigned short entry, struct keyval *kv,
+		unsigned char *mac, int num)
+{
+	int flg = (num == 1) ? 0x : 0;
+	int cipher_opt;
+	int newentry;
+	struct atheros_priv *pdata = ieee80211_priv(netdev);
+	unsigned int part1, part2, part3, part4, part5;
+
+
+	flg = 0x;
+
+	if (entry  pdata-max_keycache)
+		return 0;
+
+	switch (kv-kv_type) {
+		case CIPHER_AES_OCB:
+			cipher_opt = 5;
+			break;
+
+		case CIPHER_AES_CCM:
+			/* fixme TODO FIXME */
+			return 0;
+//			break;
+
+		case CIPHER_TKIP:
+			cipher_opt = 4;
+
+			if ((entry + 0x40)  pdata-max_keycache)
+return 0;
+
+			break;
+
+		case CIPHER_WEP:
+			if (kv-kv_len = 4)
+return 0;
+			
+			cipher_opt = 0;
+
+			if (kv

atheros driver (8/8)

2005-08-04 Thread Mateusz Berezecki


diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/other.c netdev-atheros/drivers/net/wireless/atheros/atheros5212/other.c
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/other.c	1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/other.c	2005-08-05 03:48:36.0 +0200
@@ -0,0 +1,57 @@
+/*
+ * All the work was created by reverse engineering and porting
+ * for interoperability. The creator is Mateusz Berezecki,
+ * unless explicitly marked ( some parts are derived
+ * from GPL'ed parts of madwifi project located at http://madwifi.sf.net)
+ *
+ * derived or copied parts of code licensed under
+ * dual GPL/BSD license
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ * 
+ * rest of the code has been reversed by me and is under copyright too
+ * Copyright (C) 2005  Mateusz Berezecki
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+
+#include linux/config.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/version.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pci.h
+#include linux/netdevice.h
+
+#include net/ieee80211.h
+
+#include linux/wireless.h
+#include net/iw_handler.h
+
+#include atheros_id.h
+#include atheros_dev.h
+#include atheros_defs.h
+#include atheros_registers.h
+#include atheros.h
+
+
+int ath_phy_disable(struct net_device *netdev)
+{
+	return ath_set_reset_register(netdev, AR5212_RC_BB);
+}
+
+
diff -uprN -X 'netdev-2.6.git#ieee80211/Documentation/dontdiff' netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/powermodes.c netdev-atheros/drivers/net/wireless/atheros/atheros5212/powermodes.c
--- netdev-2.6.git#ieee80211/drivers/net/wireless/atheros/atheros5212/powermodes.c	1970-01-01 01:00:00.0 +0100
+++ netdev-atheros/drivers/net/wireless/atheros/atheros5212/powermodes.c	2005-08-05 03:48:36.0 +0200
@@ -0,0 +1,155 @@
+/*
+ * All the work was created by reverse engineering and porting
+ * for interoperability. The creator is Mateusz Berezecki,
+ * unless explicitly marked ( some parts are derived
+ * from GPL'ed parts of madwifi project located at http://madwifi.sf.net)
+ *
+ * derived or copied parts of code licensed under
+ * dual GPL/BSD license
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ * 
+ * rest of the code has been reversed by me and is under copyright too
+ * Copyright (C) 2005  Mateusz Berezecki
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+
+#include linux/config.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/version.h
+#include linux/init.h
+#include linux/delay.h
+#include linux/pci.h
+#include linux/netdevice.h
+
+#include net/ieee80211.h
+
+#include linux/wireless.h
+#include net/iw_handler.h
+
+#include atheros_id.h
+#include atheros_dev.h
+#include atheros_defs.h
+//#include atheros_devops.h
+//#include atheros_regops.h
+#include atheros_registers.h
+#include atheros.h
+
+
+/* don return power mode from private device data.
+ * use hardware instead. thats better */
+POWER_MODE ath_get_power_mode(struct net_device *netdev)
+{
+	unsigned int mode = ath_reg_read(netdev, AR5212_SCR);
+	mode = (AR5212_SCR_SLE  16);
+	return mode;
+}
+
+/* zZzZ... */
+void ath_pmode_fullsleep(struct net_device *netdev, int set)
+{
+	ath_reg_enable(netdev, AR5212_STA_ID1, AR5212_STA_ID1_PWR_SV);
+	
+	if (set)
+		ath_reg_write(netdev, AR5212_SCR, 
+AR5212_SCR_SLE_SLP);
+	return;
+}
+
+/* oh, my god, its 6 am already

argh... ;/

2005-08-04 Thread Mateusz Berezecki
I accidentaly posted the patches as MIME attachments... its 5:03 am here 
already. Sorry guys.
I can resubmit if you want. I just dont want do that now and not trash 
your mailboxes


Mateusz
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html