Promiscuous mode for the wpi driver

2012-05-18 Thread Lazaros Koromilas
Just saw that damien@ has not touched the driver for a long time,
so I'm also sending this here.

- Forwarded message from Lazaros Koromilas lo...@2f30.org -

Date: Thu, 17 May 2012 15:33:59 +0300
From: Lazaros Koromilas lo...@2f30.org
To: Damien Bergamini dam...@openbsd.org
Subject: Promiscuous mode for the wpi driver
User-Agent: Mutt/1.5.21 (2010-09-15)

Hello,

I noticed that I could not put my Intel PRO/Wireless 3945ABG
in promiscuous mode, and took some time to add support for that.
If not mistaken, the WPI_CMD_ASSOCIATE means change options while
in associated state, but didn't change the name.  Patch follows.
I've only tested it with tcpdump, though.  Also, promiscuous while
in monitor mode does not make sense to me, so didn't put any checks.
Is that OK?

Thanx,
Lazaros.


Index: if_wpi.c
===
RCS file: /cvs/src/sys/dev/pci/if_wpi.c,v
retrieving revision 1.110
diff -u -p -r1.110 if_wpi.c
--- if_wpi.c2 Jun 2011 18:36:53 -   1.110
+++ if_wpi.c17 May 2012 11:57:19 -
@@ -120,6 +120,7 @@ int wpi_ioctl(struct ifnet *, u_long, c
 intwpi_cmd(struct wpi_softc *, int, const void *, int, int);
 intwpi_mrr_setup(struct wpi_softc *);
 void   wpi_updateedca(struct ieee80211com *);
+void   wpi_set_promisc(struct wpi_softc *, int);
 void   wpi_set_led(struct wpi_softc *, uint8_t, uint8_t, uint8_t);
 intwpi_set_timing(struct wpi_softc *, struct ieee80211_node *);
 void   wpi_power_calibration(struct wpi_softc *);
@@ -2002,12 +2003,21 @@ wpi_ioctl(struct ifnet *ifp, u_long cmd,
/* FALLTHROUGH */
case SIOCSIFFLAGS:
if (ifp-if_flags  IFF_UP) {
-   if (!(ifp-if_flags  IFF_RUNNING))
+   if (ifp-if_flags  IFF_RUNNING) {
+   if (ifp-if_flags  IFF_PROMISC 
+   !(sc-wpi_if_flags  IFF_PROMISC)) {
+   wpi_set_promisc(sc, 1);
+   } else if (!(ifp-if_flags  IFF_PROMISC) 
+   sc-wpi_if_flags  IFF_PROMISC) {
+   wpi_set_promisc(sc, 0);
+   }
+   } else
error = wpi_init(ifp);
} else {
if (ifp-if_flags  IFF_RUNNING)
wpi_stop(ifp, 1);
}
+   sc-wpi_if_flags = ifp-if_flags;
break;
 
case SIOCADDMULTI:
@@ -2206,6 +2216,26 @@ wpi_updateedca(struct ieee80211com *ic)
 }
 
 void
+wpi_set_promisc(struct wpi_softc *sc, int turnon)
+{
+   struct wpi_assoc cmd;
+
+   if (turnon)
+   sc-rxon.filter |= htole32(WPI_FILTER_PROMISC |
+   WPI_FILTER_CTL);
+   else
+   sc-rxon.filter = ~htole32(WPI_FILTER_PROMISC |
+   WPI_FILTER_CTL);
+
+   memset(cmd, 0, sizeof cmd);
+   cmd.flags = sc-rxon.flags;
+   cmd.filter = sc-rxon.filter;
+   cmd.ofdm_mask = sc-rxon.ofdm_mask;
+   cmd.cck_mask = sc-rxon.cck_mask;
+   (void)wpi_cmd(sc, WPI_CMD_ASSOCIATE, cmd, sizeof cmd, 1);
+}
+
+void
 wpi_set_led(struct wpi_softc *sc, uint8_t which, uint8_t off, uint8_t on)
 {
struct wpi_cmd_led led;
@@ -3327,6 +3357,7 @@ wpi_init(struct ifnet *ifp)
 
ifp-if_flags = ~IFF_OACTIVE;
ifp-if_flags |= IFF_RUNNING;
+   sc-wpi_if_flags = ifp-if_flags;
 
if (ic-ic_opmode != IEEE80211_M_MONITOR)
ieee80211_begin_scan(ifp);
Index: if_wpivar.h
===
RCS file: /cvs/src/sys/dev/pci/if_wpivar.h,v
retrieving revision 1.23
diff -u -p -r1.23 if_wpivar.h
--- if_wpivar.h 7 Sep 2010 16:21:45 -   1.23
+++ if_wpivar.h 17 May 2012 11:57:19 -
@@ -144,6 +144,8 @@ struct wpi_softc {
 #define WPI_FLAG_HAS_5GHZ  (1  0)
 #define WPI_FLAG_BUSY  (1  1)
 
+   int wpi_if_flags;
+
/* Shared area. */
struct wpi_dma_info shared_dma;
struct wpi_shared   *shared;



Re: Using MCLGETI for sk(4)

2012-05-18 Thread Stuart Henderson
On 2012/05/17 21:16, Brad Smith wrote:
 On Mon, May 07, 2012 at 10:24:37AM +0100, Stuart Henderson wrote:
  On 2012/05/06 21:34, Brad Smith wrote:
   I have resurrected the old jumbo allocator to MCLGETI conversion diff
   that was reverted with rev 1.152. The commit did not indicate why that
   was so. I updated it to -current and have tested it a fair bit on amd64
   with a SysKonnect GEnesis board using jumbos and have not found any issues
   so far. Theo or Stuart can you comment on why this was reverted?
  
  Forwarded you some mails offlist, TL;DR version is it dies under heavy
  packet load. Would be nice to have this back as the jumbo allocator uses
  a huge wodge of kvm. Not sure if I have a good machine for testing it
  any more.
 
 Ya, so I've heard but cannot reproduce any issues so far. Also test
 with a Yukon board with multiple ping -f's in both directions. Up to
 53 jumbo mbuf clusters allocated so far.
 
 
 skc0 at pci1 dev 7 function 0 Schneider  Koch SK-98xx v2.0 rev 0x20, Yukon 
 (0x1): apic 2 int 16
 sk0 at skc0 port A: address 00:00:5a:9f:31:32
 eephy0 at sk0 phy 0: 88E1011 Gigabit PHY, rev. 3

ping -f is relatively polite on the network, try something nastier like
pkg_add netrate; netblast $ip_addr $port 1 60 or tcpbench -B 1 -u $host.



Question about wscons/wsksymdef.h

2012-05-18 Thread Juan Francisco Cantero Hurtado
Hi!. This afternoon I was thinking about to change my vim config for
to remap the capslock key to control or escape keys. I was searching some
of information and I did remember the option nocaps of Xorg.

Also, I've read the man page of wsconsctl and I saw the option
swapctrlcaps. So, I decided to look the code of wscons related to this
option. I am not a C programmer but I can understand sometimes the
simple code.

In short. Can someone say me what are these values?. I don't want a
master class, just a link or a bit of documentation is sufficient.

#define KB_NODEAD   0x01 /* disable dead accents */
#define KB_DECLK0x02 /* DEC LKnnn layout */
#define KB_LK4010x04 /* DEC LK401 instead LK201 */
#define KB_SWAPCTRLCAPS 0x08 /* swap Left-Control and Caps-Lock */
#define KB_DVORAK   0x10 /* Dvorak layout */
#define KB_METAESC  0x20 /* generate ESC prefix on ALT-key */
#define KB_IOPENER  0x40 /* f1-f12 - ESC,f1-f11 */
#define KB_MACHDEP  0x80 /* machine dependent */
#define KB_APPLE0x01 /* Apple specific layout */

Thanks.

-- 
Juan Francisco Cantero Hurtado http://juanfra.info



Re: Question about wscons/wsksymdef.h

2012-05-18 Thread Matthew Dempsky
On Fri, May 18, 2012 at 4:27 PM, Juan Francisco Cantero Hurtado
i...@juanfra.info wrote:
 In short. Can someone say me what are these values?. I don't want a
 master class, just a link or a bit of documentation is sufficient.

Are you just trying to swap caps and ctrl at the console?  If so, just
put us.swapctrlcaps (or whatever) in /etc/kbdtype and reboot.  (Or
run kbd us.swapctrlcaps as root to do it instantly.)