urtwn.diff

Stefan Sperling, 03/15/2014 10:14 am

Download (6.2 kB)

sys/dev/usb/if_urtwn.c 16 Jan 2014 00:26:03 -0000
240 240
void		urtwn_temp_calib(struct urtwn_softc *);
241 241
int		urtwn_init(struct ifnet *);
242 242
void		urtwn_stop(struct ifnet *);
243
#ifndef IEEE80211_STA_ONLY
244
void		urtwn_newassoc(struct ieee80211com *, struct ieee80211_node *,
245
		    int);
246
#endif
243 247

  
244 248
/* Aliases. */
245 249
#define	urtwn_bb_write	urtwn_write_4
......
332 336
	/* Set device capabilities. */
333 337
	ic->ic_caps =
334 338
	    IEEE80211_C_MONITOR |	/* Monitor mode supported. */
339
#ifndef IEEE80211_STA_ONLY
340
	    IEEE80211_C_IBSS |		/* IBSS mode supported */
341
	    IEEE80211_C_HOSTAP |	/* HostAp mode supported */
342
#endif
335 343
	    IEEE80211_C_SHPREAMBLE |	/* Short preamble supported. */
336 344
	    IEEE80211_C_SHSLOT |	/* Short slot time supported. */
337 345
	    IEEE80211_C_WEP |		/* WEP. */
......
377 385

  
378 386
	if_attach(ifp);
379 387
	ieee80211_ifattach(ifp);
388
#ifndef IEEE80211_STA_ONLY
389
	ic->ic_newassoc = urtwn_newassoc;
390
#endif
380 391
	ic->ic_updateedca = urtwn_updateedca;
381 392
#ifdef notyet
382 393
	ic->ic_set_key = urtwn_set_key;
......
1153 1164
	usbd_ref_decr(sc->sc_udev);
1154 1165
}
1155 1166

  
1167
#ifndef IEEE80211_STA_ONLY
1168
void
1169
urtwn_newassoc(struct ieee80211com *ic, struct ieee80211_node *ni, int isnew)
1170
{
1171
	DPRINTF(("new node %s\n", ether_sprintf(ni->ni_macaddr)));
1172
	/* start with lowest Tx rate */
1173
	ni->ni_txrate = 0;
1174
}
1175
#endif
1176

  
1177

  
1156 1178
int
1157 1179
urtwn_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
1158 1180
{
......
1175 1197
	enum ieee80211_state ostate;
1176 1198
	uint32_t reg;
1177 1199
	int s;
1200
#ifndef IEEE80211_STA_ONLY
1201
	u_int8_t msr;
1202
#endif
1178 1203

  
1179 1204
	s = splnet();
1180 1205
	ostate = ic->ic_state;
......
1270 1295
		}
1271 1296
		ni = ic->ic_bss;
1272 1297

  
1298
		urtwn_set_chan(sc, ni->ni_chan, NULL);
1299

  
1273 1300
		/* Set media status to 'Associated'. */
1274 1301
		reg = urtwn_read_4(sc, R92C_CR);
1275 1302
		reg = RW(reg, R92C_CR_NETTYPE, R92C_CR_NETTYPE_INFRA);
......
1298 1325
		    urtwn_read_4(sc, R92C_RCR) |
1299 1326
		    R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN);
1300 1327

  
1328
#ifndef IEEE80211_STA_ONLY
1329
		if (ic->ic_opmode == IEEE80211_M_HOSTAP) {
1330
			urtwn_write_2(sc, R92C_BCNTCFG, 0x000f);
1331

  
1332
			/* Allow Rx from any BSSID. */
1333
			urtwn_write_4(sc, R92C_RCR,
1334
			    urtwn_read_4(sc, R92C_RCR) &
1335
			    ~(R92C_RCR_CBSSID_DATA | R92C_RCR_CBSSID_BCN));
1336

  
1337
			/* Reset TSF timer to zero. */
1338
			reg = urtwn_read_4(sc, R92C_TCR);
1339
			reg &= ~0x01;
1340
			urtwn_write_4(sc, R92C_TCR, reg);
1341
			reg |= 0x01;
1342
			urtwn_write_4(sc, R92C_TCR, reg);
1343
		}
1344

  
1345
		msr = urtwn_read_1(sc, R92C_MSR);
1346
		msr &= 0xfc;
1347
		if (ic->ic_opmode == IEEE80211_M_HOSTAP)
1348
			msr |= R92C_MSR_AP;
1349
		else if (ic->ic_opmode == IEEE80211_M_IBSS)
1350
			msr |= R92C_MSR_ADHOC;
1351
		else
1352
			msr |= R92C_MSR_INFRA;
1353
		urtwn_write_1(sc, R92C_MSR, msr);
1354
#endif
1301 1355
		/* Enable TSF synchronization. */
1302 1356
		urtwn_tsf_sync_enable(sc);
1303 1357

  
......
3118 3172

  
3119 3173
	/* Initialize beacon parameters. */
3120 3174
	urtwn_write_2(sc, R92C_TBTT_PROHIBIT, 0x6404);
3121
	urtwn_write_1(sc, R92C_DRVERLYINT, 0x05);
3122
	urtwn_write_1(sc, R92C_BCNDMATIM, 0x02);
3175
	urtwn_write_1(sc, R92C_DRVERLYINT, R92C_DRIVER_EARLY_INT_TIME); /* ms */
3176
	urtwn_write_1(sc, R92C_BCNDMATIM, R92C_DMA_ATIME_INT_TIME);
3123 3177
	urtwn_write_2(sc, R92C_BCNTCFG, 0x660f);
3124 3178

  
3125 3179
	/* Setup AMPDU aggregation. */
sys/dev/usb/if_urtwnreg.h 16 Jan 2014 00:03:21 -0000
82 82
#define R92C_SYS_CFG			0x0f0
83 83
/* MAC General Configuration. */
84 84
#define R92C_CR				0x100
85
#define R92C_MSR			0x102
85 86
#define R92C_PBP			0x104
86 87
#define R92C_TRXDMA_CTRL		0x10c
87 88
#define R92C_TRXFF_BNDY			0x114
......
187 188
/* WMAC Configuration. */
188 189
#define R92C_APSD_CTRL			0x600
189 190
#define R92C_BWOPMODE			0x603
191
#define R92C_TCR			0x604
190 192
#define R92C_RCR			0x608
191 193
#define R92C_RX_DRVINFO_SZ		0x60f
192 194
#define R92C_MACID			0x610
......
356 358
#define R92C_CR_NETTYPE_INFRA	2
357 359
#define R92C_CR_NETTYPE_AP	3
358 360

  
361
/* Bits for R92C_MSR. */
362
#define R92C_MSR_NOLINK	0x00
363
#define R92C_MSR_ADHOC	0x01
364
#define R92C_MSR_INFRA	0x02
365
#define R92C_MSR_AP	0x03
366

  
359 367
/* Bits for R92C_PBP. */
360 368
#define R92C_PBP_PSRX_M		0x0f
361 369
#define R92C_PBP_PSRX_S		0
......
454 462
#define R92C_BCN_CTRL_TXBCN_RPT		0x04
455 463
#define R92C_BCN_CTRL_EN_BCN		0x08
456 464
#define R92C_BCN_CTRL_DIS_TSF_UDT0	0x10
465

  
466
/* Bits for R92C_DRVERLYINT */
467
#define R92C_DRIVER_EARLY_INT_TIME	0x05
468

  
469
/* Bits for R92C_BCNDMATIM */
470
#define R92C_DMA_ATIME_INT_TIME		0x02
457 471

  
458 472
/* Bits for R92C_APSD_CTRL. */
459 473
#define R92C_APSD_CTRL_OFF		0x40
share/man/man4/urtwn.4 16 Jan 2014 00:27:53 -0000
50 50
mode, this is used when associating with an access point, through
51 51
which all traffic passes.
52 52
This mode is the default.
53
.It IBSS mode
54
Also known as
55
.Em IEEE ad-hoc
56
mode or
57
.Em peer-to-peer
58
mode.
59
This is the standardized method of operating without an access point.
60
Stations associate with a service set.
61
However, actual connections between stations are peer-to-peer.
62
.It Host AP
63
In this mode the driver acts as an access point (base station)
64
for other cards.
53 65
.It monitor mode
54 66
In this mode the driver is able to receive packets without
55 67
associating with an access point.