aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-04-26 10:05:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 14:00:44 -0400
commit381116e06fa31966f91f5caba8e433534da3ab85 (patch)
treedbd33b5dd5d57763279fb3dc38ec24c81613b65e
parentbbdf6e888dfd4e8c4ee748c6d8803a1d343c5def (diff)
Staging: rt3070: remove dead QOS_DLS_SUPPORT code
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/rt3070/common/action.c36
-rw-r--r--drivers/staging/rt3070/common/cmm_data.c46
-rw-r--r--drivers/staging/rt3070/common/cmm_info.c13
-rw-r--r--drivers/staging/rt3070/common/cmm_sanity.c287
-rw-r--r--drivers/staging/rt3070/common/mlme.c39
-rw-r--r--drivers/staging/rt3070/common/rtusb_io.c9
-rw-r--r--drivers/staging/rt3070/mlme.h23
-rw-r--r--drivers/staging/rt3070/oid.h26
-rw-r--r--drivers/staging/rt3070/rt_linux.c3
-rw-r--r--drivers/staging/rt3070/rt_linux.h4
-rw-r--r--drivers/staging/rt3070/rt_main_dev.c31
-rw-r--r--drivers/staging/rt3070/rt_profile.c17
-rw-r--r--drivers/staging/rt3070/rtmp.h179
-rw-r--r--drivers/staging/rt3070/rtmp_def.h4
-rw-r--r--drivers/staging/rt3070/sta/assoc.c30
-rw-r--r--drivers/staging/rt3070/sta/connect.c165
-rw-r--r--drivers/staging/rt3070/sta/dls.c2170
-rw-r--r--drivers/staging/rt3070/sta/rtmp_data.c117
-rw-r--r--drivers/staging/rt3070/sta_ioctl.c102
19 files changed, 1 insertions, 3300 deletions
diff --git a/drivers/staging/rt3070/common/action.c b/drivers/staging/rt3070/common/action.c
index 1597d7aa72d..b7a403294c3 100644
--- a/drivers/staging/rt3070/common/action.c
+++ b/drivers/staging/rt3070/common/action.c
@@ -72,9 +72,6 @@ VOID ActionStateMachineInit(
72 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE, (STATE_MACHINE_FUNC)PeerQOSAction); 72 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE, (STATE_MACHINE_FUNC)PeerQOSAction);
73 73
74 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)ReservedAction); 74 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)ReservedAction);
75#ifdef QOS_DLS_SUPPORT
76 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)PeerDLSAction);
77#endif // QOS_DLS_SUPPORT //
78 75
79#ifdef DOT11_N_SUPPORT 76#ifdef DOT11_N_SUPPORT
80 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE, (STATE_MACHINE_FUNC)PeerBAAction); 77 StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE, (STATE_MACHINE_FUNC)PeerBAAction);
@@ -291,39 +288,6 @@ VOID PeerQOSAction(
291{ 288{
292} 289}
293 290
294#ifdef QOS_DLS_SUPPORT
295VOID PeerDLSAction(
296 IN PRTMP_ADAPTER pAd,
297 IN MLME_QUEUE_ELEM *Elem)
298{
299 UCHAR Action = Elem->Msg[LENGTH_802_11+1];
300
301 switch(Action)
302 {
303 case ACTION_DLS_REQUEST:
304#ifdef CONFIG_STA_SUPPORT
305 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
306 PeerDlsReqAction(pAd, Elem);
307#endif // CONFIG_STA_SUPPORT //
308 break;
309
310 case ACTION_DLS_RESPONSE:
311#ifdef CONFIG_STA_SUPPORT
312 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
313 PeerDlsRspAction(pAd, Elem);
314#endif // CONFIG_STA_SUPPORT //
315 break;
316
317 case ACTION_DLS_TEARDOWN:
318#ifdef CONFIG_STA_SUPPORT
319 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
320 PeerDlsTearDownAction(pAd, Elem);
321#endif // CONFIG_STA_SUPPORT //
322 break;
323 }
324}
325#endif // QOS_DLS_SUPPORT //
326
327#ifdef DOT11_N_SUPPORT 291#ifdef DOT11_N_SUPPORT
328VOID PeerBAAction( 292VOID PeerBAAction(
329 IN PRTMP_ADAPTER pAd, 293 IN PRTMP_ADAPTER pAd,
diff --git a/drivers/staging/rt3070/common/cmm_data.c b/drivers/staging/rt3070/common/cmm_data.c
index a658ac17afa..93503b50c82 100644
--- a/drivers/staging/rt3070/common/cmm_data.c
+++ b/drivers/staging/rt3070/common/cmm_data.c
@@ -1249,15 +1249,6 @@ VOID RTMPWriteTxWI_Data(
1249 pTxWI->ACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAckRequired); 1249 pTxWI->ACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAckRequired);
1250 pTxWI->txop = pTxBlk->FrameGap; 1250 pTxWI->txop = pTxBlk->FrameGap;
1251 1251
1252#ifdef CONFIG_STA_SUPPORT
1253#ifdef QOS_DLS_SUPPORT
1254 if (pMacEntry &&
1255 (pAd->StaCfg.BssType == BSS_INFRA) &&
1256 (pMacEntry->ValidAsDls == TRUE))
1257 pTxWI->WirelessCliID = BSSID_WCID;
1258 else
1259#endif // QOS_DLS_SUPPORT //
1260#endif // CONFIG_STA_SUPPORT //
1261 pTxWI->WirelessCliID = pTxBlk->Wcid; 1252 pTxWI->WirelessCliID = pTxBlk->Wcid;
1262 1253
1263 pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen; 1254 pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
@@ -1876,11 +1867,6 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
1876 (pAd->MacTab.Content[i].ValidAsWDS == FALSE) && 1867 (pAd->MacTab.Content[i].ValidAsWDS == FALSE) &&
1877 (pAd->MacTab.Content[i].ValidAsApCli== FALSE) && 1868 (pAd->MacTab.Content[i].ValidAsApCli== FALSE) &&
1878 (pAd->MacTab.Content[i].ValidAsMesh == FALSE) 1869 (pAd->MacTab.Content[i].ValidAsMesh == FALSE)
1879#ifdef CONFIG_STA_SUPPORT
1880#ifdef QOS_DLS_SUPPORT
1881 && (pAd->MacTab.Content[i].ValidAsDls == FALSE)
1882#endif // QOS_DLS_SUPPORT //
1883#endif // CONFIG_STA_SUPPORT //
1884 ) 1870 )
1885 { 1871 {
1886 pEntry = &pAd->MacTab.Content[i]; 1872 pEntry = &pAd->MacTab.Content[i];
@@ -1892,20 +1878,6 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
1892 pEntry->PairwiseKey.KeyLen = 0; 1878 pEntry->PairwiseKey.KeyLen = 0;
1893 pEntry->PairwiseKey.CipherAlg = CIPHER_NONE; 1879 pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
1894 } 1880 }
1895#ifdef CONFIG_STA_SUPPORT
1896#ifdef QOS_DLS_SUPPORT
1897 if (apidx >= MIN_NET_DEVICE_FOR_DLS)
1898 {
1899 pEntry->ValidAsCLI = FALSE;
1900 pEntry->ValidAsWDS = FALSE;
1901 pEntry->ValidAsApCli = FALSE;
1902 pEntry->ValidAsMesh = FALSE;
1903 pEntry->ValidAsDls = TRUE;
1904 pEntry->isCached = FALSE;
1905 }
1906 else
1907#endif // QOS_DLS_SUPPORT //
1908#endif // CONFIG_STA_SUPPORT //
1909 { 1881 {
1910 1882
1911#ifdef CONFIG_STA_SUPPORT 1883#ifdef CONFIG_STA_SUPPORT
@@ -1934,12 +1906,6 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
1934 pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_APCLI); 1906 pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_APCLI);
1935 else if (pEntry->ValidAsWDS) 1907 else if (pEntry->ValidAsWDS)
1936 pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_WDS); 1908 pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_WDS);
1937#ifdef CONFIG_STA_SUPPORT
1938#ifdef QOS_DLS_SUPPORT
1939 else if (pEntry->ValidAsDls)
1940 pEntry->apidx = (apidx - MIN_NET_DEVICE_FOR_DLS);
1941#endif // QOS_DLS_SUPPORT //
1942#endif // CONFIG_STA_SUPPORT //
1943 else 1909 else
1944 pEntry->apidx = apidx; 1910 pEntry->apidx = apidx;
1945 1911
@@ -1958,13 +1924,6 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
1958 pEntry->GTKState = REKEY_NEGOTIATING; 1924 pEntry->GTKState = REKEY_NEGOTIATING;
1959 pEntry->PairwiseKey.KeyLen = 0; 1925 pEntry->PairwiseKey.KeyLen = 0;
1960 pEntry->PairwiseKey.CipherAlg = CIPHER_NONE; 1926 pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
1961#ifdef CONFIG_STA_SUPPORT
1962#ifdef QOS_DLS_SUPPORT
1963 if (pEntry->ValidAsDls == TRUE)
1964 pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
1965 else
1966#endif //QOS_DLS_SUPPORT
1967#endif // CONFIG_STA_SUPPORT //
1968 pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED; 1927 pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1969 pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND; 1928 pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND;
1970 COPY_MAC_ADDR(pEntry->Addr, pAddr); 1929 COPY_MAC_ADDR(pEntry->Addr, pAddr);
@@ -2039,11 +1998,6 @@ BOOLEAN MacTableDeleteEntry(
2039 pEntry = &pAd->MacTab.Content[wcid]; 1998 pEntry = &pAd->MacTab.Content[wcid];
2040 1999
2041 if (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsApCli || pEntry->ValidAsWDS || pEntry->ValidAsMesh 2000 if (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsApCli || pEntry->ValidAsWDS || pEntry->ValidAsMesh
2042#ifdef CONFIG_STA_SUPPORT
2043#ifdef QOS_DLS_SUPPORT
2044 || pEntry->ValidAsDls
2045#endif // QOS_DLS_SUPPORT //
2046#endif // CONFIG_STA_SUPPORT //
2047 )) 2001 ))
2048 { 2002 {
2049 if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr)) 2003 if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
diff --git a/drivers/staging/rt3070/common/cmm_info.c b/drivers/staging/rt3070/common/cmm_info.c
index c514c90fdd8..7344d39135a 100644
--- a/drivers/staging/rt3070/common/cmm_info.c
+++ b/drivers/staging/rt3070/common/cmm_info.c
@@ -1715,11 +1715,6 @@ VOID RTMPAddWcidAttributeEntry(
1715 Wcid = pEntry->Aid; 1715 Wcid = pEntry->Aid;
1716 else if (pEntry && INFRA_ON(pAd)) 1716 else if (pEntry && INFRA_ON(pAd))
1717 { 1717 {
1718#ifdef QOS_DLS_SUPPORT
1719 if (pEntry->ValidAsDls == TRUE)
1720 Wcid = pEntry->Aid;
1721 else
1722#endif // QOS_DLS_SUPPORT //
1723 Wcid = BSSID_WCID; 1718 Wcid = BSSID_WCID;
1724 } 1719 }
1725 else 1720 else
@@ -1736,14 +1731,6 @@ VOID RTMPAddWcidAttributeEntry(
1736 { 1731 {
1737 if (pEntry && pEntry->ValidAsMesh) 1732 if (pEntry && pEntry->ValidAsMesh)
1738 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE; 1733 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
1739#ifdef QOS_DLS_SUPPORT
1740 else if ((pEntry) && (pEntry->ValidAsDls) &&
1741 ((CipherAlg == CIPHER_TKIP) ||
1742 (CipherAlg == CIPHER_TKIP_NO_MIC) ||
1743 (CipherAlg == CIPHER_AES) ||
1744 (CipherAlg == CIPHER_NONE)))
1745 WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
1746#endif // QOS_DLS_SUPPORT //
1747 else 1734 else
1748 WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE; 1735 WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
1749 } 1736 }
diff --git a/drivers/staging/rt3070/common/cmm_sanity.c b/drivers/staging/rt3070/common/cmm_sanity.c
index 6118df8de7b..ce36c279cef 100644
--- a/drivers/staging/rt3070/common/cmm_sanity.c
+++ b/drivers/staging/rt3070/common/cmm_sanity.c
@@ -1380,290 +1380,3 @@ BOOLEAN PeerWpaMessageSanity(
1380 return TRUE; 1380 return TRUE;
1381 1381
1382} 1382}
1383
1384#ifdef CONFIG_STA_SUPPORT
1385#ifdef QOS_DLS_SUPPORT
1386BOOLEAN MlmeDlsReqSanity(
1387 IN PRTMP_ADAPTER pAd,
1388 IN VOID *Msg,
1389 IN ULONG MsgLen,
1390 OUT PRT_802_11_DLS *pDLS,
1391 OUT PUSHORT pReason)
1392{
1393 MLME_DLS_REQ_STRUCT *pInfo;
1394
1395 pInfo = (MLME_DLS_REQ_STRUCT *)Msg;
1396
1397 *pDLS = pInfo->pDLS;
1398 *pReason = pInfo->Reason;
1399
1400 return TRUE;
1401}
1402#endif // QOS_DLS_SUPPORT //
1403#endif // CONFIG_STA_SUPPORT //
1404
1405#ifdef QOS_DLS_SUPPORT
1406BOOLEAN PeerDlsReqSanity(
1407 IN PRTMP_ADAPTER pAd,
1408 IN VOID *Msg,
1409 IN ULONG MsgLen,
1410 OUT PUCHAR pDA,
1411 OUT PUCHAR pSA,
1412 OUT USHORT *pCapabilityInfo,
1413 OUT USHORT *pDlsTimeout,
1414 OUT UCHAR *pRatesLen,
1415 OUT UCHAR Rates[],
1416 OUT UCHAR *pHtCapabilityLen,
1417 OUT HT_CAPABILITY_IE *pHtCapability)
1418{
1419 CHAR *Ptr;
1420 PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
1421 PEID_STRUCT eid_ptr;
1422
1423 // to prevent caller from using garbage output value
1424 *pCapabilityInfo = 0;
1425 *pDlsTimeout = 0;
1426 *pHtCapabilityLen = 0;
1427
1428 Ptr = Fr->Octet;
1429
1430 // offset to destination MAC address (Category and Action field)
1431 Ptr += 2;
1432
1433 // get DA from payload and advance the pointer
1434 NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
1435 Ptr += MAC_ADDR_LEN;
1436
1437 // get SA from payload and advance the pointer
1438 NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
1439 Ptr += MAC_ADDR_LEN;
1440
1441 // get capability info from payload and advance the pointer
1442 NdisMoveMemory(pCapabilityInfo, Ptr, 2);
1443 Ptr += 2;
1444
1445 // get capability info from payload and advance the pointer
1446 NdisMoveMemory(pDlsTimeout, Ptr, 2);
1447 Ptr += 2;
1448
1449 // Category and Action field + DA + SA + capability + Timeout
1450 eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
1451
1452 while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
1453 {
1454 switch(eid_ptr->Eid)
1455 {
1456 case IE_SUPP_RATES:
1457 if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
1458 {
1459 NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
1460 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
1461 DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
1462 *pRatesLen = eid_ptr->Len;
1463 }
1464 else
1465 {
1466 *pRatesLen = 8;
1467 Rates[0] = 0x82;
1468 Rates[1] = 0x84;
1469 Rates[2] = 0x8b;
1470 Rates[3] = 0x96;
1471 Rates[4] = 0x12;
1472 Rates[5] = 0x24;
1473 Rates[6] = 0x48;
1474 Rates[7] = 0x6c;
1475 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
1476 }
1477 break;
1478
1479 case IE_EXT_SUPP_RATES:
1480 if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
1481 {
1482 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
1483 *pRatesLen = (*pRatesLen) + eid_ptr->Len;
1484 }
1485 else
1486 {
1487 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
1488 *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
1489 }
1490 break;
1491
1492 case IE_HT_CAP:
1493 if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
1494 {
1495 NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
1496
1497 *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
1498 *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
1499 *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
1500
1501 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - IE_HT_CAP\n"));
1502 }
1503 else
1504 {
1505 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsReqSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
1506 }
1507 break;
1508
1509 default:
1510 break;
1511 }
1512
1513 eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
1514 }
1515
1516 return TRUE;
1517}
1518
1519BOOLEAN PeerDlsRspSanity(
1520 IN PRTMP_ADAPTER pAd,
1521 IN VOID *Msg,
1522 IN ULONG MsgLen,
1523 OUT PUCHAR pDA,
1524 OUT PUCHAR pSA,
1525 OUT USHORT *pCapabilityInfo,
1526 OUT USHORT *pStatus,
1527 OUT UCHAR *pRatesLen,
1528 OUT UCHAR Rates[],
1529 OUT UCHAR *pHtCapabilityLen,
1530 OUT HT_CAPABILITY_IE *pHtCapability)
1531{
1532 CHAR *Ptr;
1533 PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
1534 PEID_STRUCT eid_ptr;
1535
1536 // to prevent caller from using garbage output value
1537 *pStatus = 0;
1538 *pCapabilityInfo = 0;
1539 *pHtCapabilityLen = 0;
1540
1541 Ptr = Fr->Octet;
1542
1543 // offset to destination MAC address (Category and Action field)
1544 Ptr += 2;
1545
1546 // get status code from payload and advance the pointer
1547 NdisMoveMemory(pStatus, Ptr, 2);
1548 Ptr += 2;
1549
1550 // get DA from payload and advance the pointer
1551 NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
1552 Ptr += MAC_ADDR_LEN;
1553
1554 // get SA from payload and advance the pointer
1555 NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
1556 Ptr += MAC_ADDR_LEN;
1557
1558 if (pStatus == 0)
1559 {
1560 // get capability info from payload and advance the pointer
1561 NdisMoveMemory(pCapabilityInfo, Ptr, 2);
1562 Ptr += 2;
1563 }
1564
1565 // Category and Action field + status code + DA + SA + capability
1566 eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
1567
1568 while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
1569 {
1570 switch(eid_ptr->Eid)
1571 {
1572 case IE_SUPP_RATES:
1573 if ((eid_ptr->Len <= MAX_LEN_OF_SUPPORTED_RATES) && (eid_ptr->Len > 0))
1574 {
1575 NdisMoveMemory(Rates, eid_ptr->Octet, eid_ptr->Len);
1576 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_SUPP_RATES., Len=%d. Rates[0]=%x\n",eid_ptr->Len, Rates[0]));
1577 DBGPRINT(RT_DEBUG_TRACE, ("Rates[1]=%x %x %x %x %x %x %x\n", Rates[1], Rates[2], Rates[3], Rates[4], Rates[5], Rates[6], Rates[7]));
1578 *pRatesLen = eid_ptr->Len;
1579 }
1580 else
1581 {
1582 *pRatesLen = 8;
1583 Rates[0] = 0x82;
1584 Rates[1] = 0x84;
1585 Rates[2] = 0x8b;
1586 Rates[3] = 0x96;
1587 Rates[4] = 0x12;
1588 Rates[5] = 0x24;
1589 Rates[6] = 0x48;
1590 Rates[7] = 0x6c;
1591 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_SUPP_RATES., Len=%d\n",eid_ptr->Len));
1592 }
1593 break;
1594
1595 case IE_EXT_SUPP_RATES:
1596 if (eid_ptr->Len + *pRatesLen <= MAX_LEN_OF_SUPPORTED_RATES)
1597 {
1598 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, eid_ptr->Len);
1599 *pRatesLen = (*pRatesLen) + eid_ptr->Len;
1600 }
1601 else
1602 {
1603 NdisMoveMemory(&Rates[*pRatesLen], eid_ptr->Octet, MAX_LEN_OF_SUPPORTED_RATES - (*pRatesLen));
1604 *pRatesLen = MAX_LEN_OF_SUPPORTED_RATES;
1605 }
1606 break;
1607
1608 case IE_HT_CAP:
1609 if (eid_ptr->Len >= sizeof(HT_CAPABILITY_IE))
1610 {
1611 NdisMoveMemory(pHtCapability, eid_ptr->Octet, sizeof(HT_CAPABILITY_IE));
1612
1613 *(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
1614 *(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
1615 *pHtCapabilityLen = sizeof(HT_CAPABILITY_IE);
1616
1617 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - IE_HT_CAP\n"));
1618 }
1619 else
1620 {
1621 DBGPRINT(RT_DEBUG_TRACE, ("PeerDlsRspSanity - wrong IE_HT_CAP.eid_ptr->Len = %d\n", eid_ptr->Len));
1622 }
1623 break;
1624
1625 default:
1626 break;
1627 }
1628
1629 eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
1630 }
1631
1632 return TRUE;
1633}
1634
1635BOOLEAN PeerDlsTearDownSanity(
1636 IN PRTMP_ADAPTER pAd,
1637 IN VOID *Msg,
1638 IN ULONG MsgLen,
1639 OUT PUCHAR pDA,
1640 OUT PUCHAR pSA,
1641 OUT USHORT *pReason)
1642{
1643 CHAR *Ptr;
1644 PFRAME_802_11 Fr = (PFRAME_802_11)Msg;
1645
1646 // to prevent caller from using garbage output value
1647 *pReason = 0;
1648
1649 Ptr = Fr->Octet;
1650
1651 // offset to destination MAC address (Category and Action field)
1652 Ptr += 2;
1653
1654 // get DA from payload and advance the pointer
1655 NdisMoveMemory(pDA, Ptr, MAC_ADDR_LEN);
1656 Ptr += MAC_ADDR_LEN;
1657
1658 // get SA from payload and advance the pointer
1659 NdisMoveMemory(pSA, Ptr, MAC_ADDR_LEN);
1660 Ptr += MAC_ADDR_LEN;
1661
1662 // get reason code from payload and advance the pointer
1663 NdisMoveMemory(pReason, Ptr, 2);
1664 Ptr += 2;
1665
1666 return TRUE;
1667}
1668#endif // QOS_DLS_SUPPORT //
1669
diff --git a/drivers/staging/rt3070/common/mlme.c b/drivers/staging/rt3070/common/mlme.c
index 537b157bde3..a33a069b7d2 100644
--- a/drivers/staging/rt3070/common/mlme.c
+++ b/drivers/staging/rt3070/common/mlme.c
@@ -511,11 +511,6 @@ NDIS_STATUS MlmeInit(
511 WpaPskStateMachineInit(pAd, &pAd->Mlme.WpaPskMachine, pAd->Mlme.WpaPskFunc); 511 WpaPskStateMachineInit(pAd, &pAd->Mlme.WpaPskMachine, pAd->Mlme.WpaPskFunc);
512 AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc); 512 AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc);
513 513
514#ifdef QOS_DLS_SUPPORT
515 DlsStateMachineInit(pAd, &pAd->Mlme.DlsMachine, pAd->Mlme.DlsFunc);
516#endif // QOS_DLS_SUPPORT //
517
518
519 // Since we are using switch/case to implement it, the init is different from the above 514 // Since we are using switch/case to implement it, the init is different from the above
520 // state machine init 515 // state machine init
521 MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL); 516 MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL);
@@ -635,12 +630,6 @@ VOID MlmeHandler(
635 case AIRONET_STATE_MACHINE: 630 case AIRONET_STATE_MACHINE:
636 StateMachinePerformAction(pAd, &pAd->Mlme.AironetMachine, Elem); 631 StateMachinePerformAction(pAd, &pAd->Mlme.AironetMachine, Elem);
637 break; 632 break;
638
639#ifdef QOS_DLS_SUPPORT
640 case DLS_STATE_MACHINE:
641 StateMachinePerformAction(pAd, &pAd->Mlme.DlsMachine, Elem);
642 break;
643#endif // QOS_DLS_SUPPORT //
644#endif // CONFIG_STA_SUPPORT // 633#endif // CONFIG_STA_SUPPORT //
645 634
646 case ACTION_STATE_MACHINE: 635 case ACTION_STATE_MACHINE:
@@ -702,9 +691,6 @@ VOID MlmeHalt(
702#ifdef CONFIG_STA_SUPPORT 691#ifdef CONFIG_STA_SUPPORT
703 IF_DEV_CONFIG_OPMODE_ON_STA(pAd) 692 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
704 { 693 {
705#ifdef QOS_DLS_SUPPORT
706 UCHAR i;
707#endif // QOS_DLS_SUPPORT //
708 // Cancel pending timers 694 // Cancel pending timers
709 RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled); 695 RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
710 RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled); 696 RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
@@ -712,13 +698,6 @@ VOID MlmeHalt(
712 RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled); 698 RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
713 RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled); 699 RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
714 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled); 700 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
715
716#ifdef QOS_DLS_SUPPORT
717 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
718 {
719 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
720 }
721#endif // QOS_DLS_SUPPORT //
722 } 701 }
723#endif // CONFIG_STA_SUPPORT // 702#endif // CONFIG_STA_SUPPORT //
724 703
@@ -1048,11 +1027,6 @@ VOID STAMlmePeriodicExec(
1048 1027
1049 if (INFRA_ON(pAd)) 1028 if (INFRA_ON(pAd))
1050 { 1029 {
1051#ifdef QOS_DLS_SUPPORT
1052 // Check DLS time out, then tear down those session
1053 RTMPCheckDLSTimeOut(pAd);
1054#endif // QOS_DLS_SUPPORT //
1055
1056 // Is PSM bit consistent with user power management policy? 1030 // Is PSM bit consistent with user power management policy?
1057 // This is the only place that will set PSM bit ON. 1031 // This is the only place that will set PSM bit ON.
1058 if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) 1032 if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
@@ -4896,9 +4870,6 @@ VOID MlmeRestartStateMachine(
4896#ifdef CONFIG_STA_SUPPORT 4870#ifdef CONFIG_STA_SUPPORT
4897 IF_DEV_CONFIG_OPMODE_ON_STA(pAd) 4871 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
4898 { 4872 {
4899#ifdef QOS_DLS_SUPPORT
4900 UCHAR i;
4901#endif // QOS_DLS_SUPPORT //
4902 // Cancel all timer events 4873 // Cancel all timer events
4903 // Be careful to cancel new added timer 4874 // Be careful to cancel new added timer
4904 RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled); 4875 RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
@@ -4907,13 +4878,6 @@ VOID MlmeRestartStateMachine(
4907 RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled); 4878 RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
4908 RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled); 4879 RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
4909 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled); 4880 RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
4910
4911#ifdef QOS_DLS_SUPPORT
4912 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
4913 {
4914 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);
4915 }
4916#endif // QOS_DLS_SUPPORT //
4917 } 4881 }
4918#endif // CONFIG_STA_SUPPORT // 4882#endif // CONFIG_STA_SUPPORT //
4919 4883
@@ -4934,9 +4898,6 @@ VOID MlmeRestartStateMachine(
4934 pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE; 4898 pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
4935 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; 4899 pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
4936 pAd->Mlme.ActMachine.CurrState = ACT_IDLE; 4900 pAd->Mlme.ActMachine.CurrState = ACT_IDLE;
4937#ifdef QOS_DLS_SUPPORT
4938 pAd->Mlme.DlsMachine.CurrState = DLS_IDLE;
4939#endif // QOS_DLS_SUPPORT //
4940 } 4901 }
4941#endif // CONFIG_STA_SUPPORT // 4902#endif // CONFIG_STA_SUPPORT //
4942 4903
diff --git a/drivers/staging/rt3070/common/rtusb_io.c b/drivers/staging/rt3070/common/rtusb_io.c
index 01153b7d59e..d21a830eb5b 100644
--- a/drivers/staging/rt3070/common/rtusb_io.c
+++ b/drivers/staging/rt3070/common/rtusb_io.c
@@ -1673,15 +1673,6 @@ VOID CMDHandler(
1673 1673
1674 pEntry = (PMAC_TABLE_ENTRY)(pData); 1674 pEntry = (PMAC_TABLE_ENTRY)(pData);
1675 1675
1676#ifdef CONFIG_STA_SUPPORT
1677#ifdef QOS_DLS_SUPPORT
1678 KeyIdx = 0;
1679 CipherAlg = pEntry->PairwiseKey.CipherAlg;
1680 ApIdx = BSS0;
1681#endif // QOS_DLS_SUPPORT //
1682#endif // CONFIG_STA_SUPPORT //
1683
1684
1685 RTMPAddWcidAttributeEntry( 1676 RTMPAddWcidAttributeEntry(
1686 pAd, 1677 pAd,
1687 ApIdx, 1678 ApIdx,
diff --git a/drivers/staging/rt3070/mlme.h b/drivers/staging/rt3070/mlme.h
index f1bda4fcada..e84325ed084 100644
--- a/drivers/staging/rt3070/mlme.h
+++ b/drivers/staging/rt3070/mlme.h
@@ -1342,29 +1342,6 @@ typedef struct _MLME_START_REQ_STRUCT {
1342 UCHAR SsidLen; 1342 UCHAR SsidLen;
1343} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT; 1343} MLME_START_REQ_STRUCT, *PMLME_START_REQ_STRUCT;
1344 1344
1345#ifdef CONFIG_STA_SUPPORT
1346#ifdef QOS_DLS_SUPPORT
1347// structure for DLS
1348typedef struct _RT_802_11_DLS {
1349 USHORT TimeOut; // Use to time out while slience, unit: second , set by UI
1350 USHORT CountDownTimer; // Use to time out while slience,unit: second , used by driver only
1351 NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
1352 UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
1353 BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
1354 RALINK_TIMER_STRUCT Timer; // Use to time out while handshake
1355 USHORT Sequence;
1356 USHORT MacTabMatchWCID; // ASIC
1357 BOOLEAN bHTCap;
1358 PVOID pAd;
1359} RT_802_11_DLS, *PRT_802_11_DLS;
1360
1361typedef struct _MLME_DLS_REQ_STRUCT {
1362 PRT_802_11_DLS pDLS;
1363 USHORT Reason;
1364} MLME_DLS_REQ_STRUCT, *PMLME_DLS_REQ_STRUCT;
1365#endif // QOS_DLS_SUPPORT //
1366#endif // CONFIG_STA_SUPPORT //
1367
1368typedef struct PACKED { 1345typedef struct PACKED {
1369 UCHAR Eid; 1346 UCHAR Eid;
1370 UCHAR Len; 1347 UCHAR Len;
diff --git a/drivers/staging/rt3070/oid.h b/drivers/staging/rt3070/oid.h
index 63437a929dd..83374562a84 100644
--- a/drivers/staging/rt3070/oid.h
+++ b/drivers/staging/rt3070/oid.h
@@ -683,9 +683,6 @@ enum {
683#endif // RT2870 // 683#endif // RT2870 //
684 RAIO_OFF = 10, 684 RAIO_OFF = 10,
685 RAIO_ON = 11, 685 RAIO_ON = 11,
686#ifdef QOS_DLS_SUPPORT
687 SHOW_DLS_ENTRY_INFO = 19,
688#endif // QOS_DLS_SUPPORT //
689 SHOW_CFG_VALUE = 20, 686 SHOW_CFG_VALUE = 20,
690}; 687};
691 688
@@ -990,29 +987,6 @@ typedef struct _RT_LLTD_ASSOICATION_TABLE {
990#endif // LLTD_SUPPORT // 987#endif // LLTD_SUPPORT //
991 988
992#ifdef CONFIG_STA_SUPPORT 989#ifdef CONFIG_STA_SUPPORT
993#ifdef QOS_DLS_SUPPORT
994//rt2860, kathy 2007-0118
995// structure for DLS
996typedef struct _RT_802_11_DLS_UI {
997 USHORT TimeOut; // unit: second , set by UI
998 USHORT CountDownTimer; // unit: second , used by driver only
999 NDIS_802_11_MAC_ADDRESS MacAddr; // set by UI
1000 UCHAR Status; // 0: none , 1: wait STAkey, 2: finish DLS setup , set by driver only
1001 BOOLEAN Valid; // 1: valid , 0: invalid , set by UI, use to setup or tear down DLS link
1002} RT_802_11_DLS_UI, *PRT_802_11_DLS_UI;
1003
1004typedef struct _RT_802_11_DLS_INFO {
1005 RT_802_11_DLS_UI Entry[MAX_NUMBER_OF_DLS_ENTRY];
1006 UCHAR num;
1007} RT_802_11_DLS_INFO, *PRT_802_11_DLS_INFO;
1008
1009typedef enum _RT_802_11_DLS_MODE {
1010 DLS_NONE,
1011 DLS_WAIT_KEY,
1012 DLS_FINISH
1013} RT_802_11_DLS_MODE;
1014#endif // QOS_DLS_SUPPORT //
1015
1016#ifdef WPA_SUPPLICANT_SUPPORT 990#ifdef WPA_SUPPLICANT_SUPPORT
1017#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT 991#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
1018#define RT_ASSOC_EVENT_FLAG 0x0101 992#define RT_ASSOC_EVENT_FLAG 0x0101
diff --git a/drivers/staging/rt3070/rt_linux.c b/drivers/staging/rt3070/rt_linux.c
index f785a9a0a68..252c63a4e95 100644
--- a/drivers/staging/rt3070/rt_linux.c
+++ b/drivers/staging/rt3070/rt_linux.c
@@ -52,9 +52,6 @@ BUILD_TIMER_FUNCTION(LeapAuthTimeout);
52#endif 52#endif
53BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec); 53BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
54BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc); 54BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
55#ifdef QOS_DLS_SUPPORT
56BUILD_TIMER_FUNCTION(DlsTimeoutAction);
57#endif // QOS_DLS_SUPPORT //
58#endif // CONFIG_STA_SUPPORT // 55#endif // CONFIG_STA_SUPPORT //
59 56
60 57
diff --git a/drivers/staging/rt3070/rt_linux.h b/drivers/staging/rt3070/rt_linux.h
index e8638920469..a18c41615b2 100644
--- a/drivers/staging/rt3070/rt_linux.h
+++ b/drivers/staging/rt3070/rt_linux.h
@@ -529,10 +529,6 @@ DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
529DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc); 529DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
530DECLARE_TIMER_FUNCTION(PsPollWakeExec); 530DECLARE_TIMER_FUNCTION(PsPollWakeExec);
531DECLARE_TIMER_FUNCTION(RadioOnExec); 531DECLARE_TIMER_FUNCTION(RadioOnExec);
532
533#ifdef QOS_DLS_SUPPORT
534DECLARE_TIMER_FUNCTION(DlsTimeoutAction);
535#endif // QOS_DLS_SUPPORT //
536#endif // CONFIG_STA_SUPPORT // 532#endif // CONFIG_STA_SUPPORT //
537 533
538void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time); 534void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
diff --git a/drivers/staging/rt3070/rt_main_dev.c b/drivers/staging/rt3070/rt_main_dev.c
index b73b1ffcda5..cf645c21d92 100644
--- a/drivers/staging/rt3070/rt_main_dev.c
+++ b/drivers/staging/rt3070/rt_main_dev.c
@@ -217,37 +217,6 @@ int rt28xx_close(IN PNET_DEV dev)
217 AsicForceWakeup(pAd, TRUE); 217 AsicForceWakeup(pAd, TRUE);
218 } 218 }
219 219
220#ifdef QOS_DLS_SUPPORT
221 // send DLS-TEAR_DOWN message,
222 if (pAd->CommonCfg.bDLSCapable)
223 {
224 UCHAR i;
225
226 // tear down local dls table entry
227 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
228 {
229 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
230 {
231 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
232 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
233 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
234 }
235 }
236
237 // tear down peer dls table entry
238 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
239 {
240 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
241 {
242 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
243 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
244 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
245 }
246 }
247 RT28XX_MLME_HANDLER(pAd);
248 }
249#endif // QOS_DLS_SUPPORT //
250
251 if (INFRA_ON(pAd) && 220 if (INFRA_ON(pAd) &&
252 (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) 221 (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
253 { 222 {
diff --git a/drivers/staging/rt3070/rt_profile.c b/drivers/staging/rt3070/rt_profile.c
index 46865c146af..a89f3fe6ca2 100644
--- a/drivers/staging/rt3070/rt_profile.c
+++ b/drivers/staging/rt3070/rt_profile.c
@@ -821,23 +821,6 @@ static void rtmp_read_sta_wmm_parms_from_file(IN PRTMP_ADAPTER pAd, char *tmpbu
821 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable)); 821 DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
822 } 822 }
823 823
824#ifdef QOS_DLS_SUPPORT
825 //DLSCapable
826 if(RTMPGetKeyParameter("DLSCapable", tmpbuf, 32, buffer))
827 {
828 if(simple_strtol(tmpbuf, 0, 10) != 0) //Enable
829 {
830 pAd->CommonCfg.bDLSCapable = TRUE;
831 }
832 else //Disable
833 {
834 pAd->CommonCfg.bDLSCapable = FALSE;
835 }
836
837 DBGPRINT(RT_DEBUG_TRACE, ("bDLSCapable=%d\n", pAd->CommonCfg.bDLSCapable));
838 }
839#endif // QOS_DLS_SUPPORT //
840
841 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO 824 //AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
842 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer)) 825 if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
843 { 826 {
diff --git a/drivers/staging/rt3070/rtmp.h b/drivers/staging/rt3070/rtmp.h
index 7e83079f411..7842ac09080 100644
--- a/drivers/staging/rt3070/rtmp.h
+++ b/drivers/staging/rt3070/rtmp.h
@@ -1324,15 +1324,6 @@ typedef struct _MLME_STRUCT {
1324 // Action 1324 // Action
1325 STATE_MACHINE ActMachine; 1325 STATE_MACHINE ActMachine;
1326 1326
1327
1328#ifdef QOS_DLS_SUPPORT
1329 STATE_MACHINE DlsMachine;
1330 STATE_MACHINE_FUNC DlsFunc[DLS_FUNC_SIZE];
1331#endif // QOS_DLS_SUPPORT //
1332
1333
1334
1335
1336 ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming 1327 ULONG ChannelQuality; // 0..100, Channel Quality Indication for Roaming
1337 ULONG Now32; // latch the value of NdisGetSystemUpTime() 1328 ULONG Now32; // latch the value of NdisGetSystemUpTime()
1338 ULONG LastSendNULLpsmTime; 1329 ULONG LastSendNULLpsmTime;
@@ -2126,10 +2117,6 @@ typedef struct _STA_ADMIN_CONFIG {
2126 UCHAR DtimCount; // 0.. DtimPeriod-1 2117 UCHAR DtimCount; // 0.. DtimPeriod-1
2127 UCHAR DtimPeriod; // default = 3 2118 UCHAR DtimPeriod; // default = 3
2128 2119
2129#ifdef QOS_DLS_SUPPORT
2130 RT_802_11_DLS DLSEntry[MAX_NUM_OF_DLS_ENTRY];
2131 UCHAR DlsReplayCounter[8];
2132#endif // QOS_DLS_SUPPORT //
2133 //////////////////////////////////////////////////////////////////////////////////////// 2120 ////////////////////////////////////////////////////////////////////////////////////////
2134 // This is only for WHQL test. 2121 // This is only for WHQL test.
2135 BOOLEAN WhqlTest; 2122 BOOLEAN WhqlTest;
@@ -2301,14 +2288,6 @@ typedef struct _MAC_TABLE_ENTRY {
2301 UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition 2288 UCHAR TxRateUpPenalty; // extra # of second penalty due to last unstable condition
2302//==================================================== 2289//====================================================
2303 2290
2304
2305
2306#ifdef CONFIG_STA_SUPPORT
2307#ifdef QOS_DLS_SUPPORT
2308 UINT MatchDlsEntryIdx; // indicate the index in pAd->StaCfg.DLSEntry
2309#endif // QOS_DLS_SUPPORT //
2310#endif // CONFIG_STA_SUPPORT //
2311
2312 BOOLEAN fNoisyEnvironment; 2291 BOOLEAN fNoisyEnvironment;
2313 BOOLEAN fLastSecAccordingRSSI; 2292 BOOLEAN fLastSecAccordingRSSI;
2314 UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down 2293 UCHAR LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
@@ -3732,22 +3711,6 @@ VOID PeerQOSAction(
3732 IN PRTMP_ADAPTER pAd, 3711 IN PRTMP_ADAPTER pAd,
3733 IN MLME_QUEUE_ELEM *Elem); 3712 IN MLME_QUEUE_ELEM *Elem);
3734 3713
3735#ifdef QOS_DLS_SUPPORT
3736VOID PeerDLSAction(
3737 IN PRTMP_ADAPTER pAd,
3738 IN MLME_QUEUE_ELEM *Elem);
3739#endif // QOS_DLS_SUPPORT //
3740
3741#ifdef CONFIG_STA_SUPPORT
3742#ifdef QOS_DLS_SUPPORT
3743VOID DlsParmFill(
3744 IN PRTMP_ADAPTER pAd,
3745 IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
3746 IN PRT_802_11_DLS pDls,
3747 IN USHORT reason);
3748#endif // QOS_DLS_SUPPORT //
3749#endif // CONFIG_STA_SUPPORT //
3750
3751#ifdef DOT11_N_SUPPORT 3714#ifdef DOT11_N_SUPPORT
3752VOID RECBATimerTimeout( 3715VOID RECBATimerTimeout(
3753 IN PVOID SystemSpecific1, 3716 IN PVOID SystemSpecific1,
@@ -4679,142 +4642,6 @@ VOID PeerAuthSimpleRspGenAndSend(
4679// Private routines in dls.c 4642// Private routines in dls.c
4680// 4643//
4681 4644
4682#ifdef CONFIG_STA_SUPPORT
4683#ifdef QOS_DLS_SUPPORT
4684void DlsStateMachineInit(
4685 IN PRTMP_ADAPTER pAd,
4686 IN STATE_MACHINE *Sm,
4687 OUT STATE_MACHINE_FUNC Trans[]);
4688
4689VOID MlmeDlsReqAction(
4690 IN PRTMP_ADAPTER pAd,
4691 IN MLME_QUEUE_ELEM *Elem);
4692
4693VOID PeerDlsReqAction(
4694 IN PRTMP_ADAPTER pAd,
4695 IN MLME_QUEUE_ELEM *Elem);
4696
4697VOID PeerDlsRspAction(
4698 IN PRTMP_ADAPTER pAd,
4699 IN MLME_QUEUE_ELEM *Elem);
4700
4701VOID MlmeDlsTearDownAction(
4702 IN PRTMP_ADAPTER pAd,
4703 IN MLME_QUEUE_ELEM *Elem);
4704
4705VOID PeerDlsTearDownAction(
4706 IN PRTMP_ADAPTER pAd,
4707 IN MLME_QUEUE_ELEM *Elem);
4708
4709VOID RTMPCheckDLSTimeOut(
4710 IN PRTMP_ADAPTER pAd);
4711
4712BOOLEAN RTMPRcvFrameDLSCheck(
4713 IN PRTMP_ADAPTER pAd,
4714 IN PHEADER_802_11 pHeader,
4715 IN ULONG Len,
4716 IN PRT28XX_RXD_STRUC pRxD);
4717
4718INT RTMPCheckDLSFrame(
4719 IN PRTMP_ADAPTER pAd,
4720 IN PUCHAR pDA);
4721
4722VOID RTMPSendDLSTearDownFrame(
4723 IN PRTMP_ADAPTER pAd,
4724 IN PUCHAR pDA);
4725
4726NDIS_STATUS RTMPSendSTAKeyRequest(
4727 IN PRTMP_ADAPTER pAd,
4728 IN PUCHAR pDA);
4729
4730NDIS_STATUS RTMPSendSTAKeyHandShake(
4731 IN PRTMP_ADAPTER pAd,
4732 IN PUCHAR pDA);
4733
4734VOID DlsTimeoutAction(
4735 IN PVOID SystemSpecific1,
4736 IN PVOID FunctionContext,
4737 IN PVOID SystemSpecific2,
4738 IN PVOID SystemSpecific3);
4739
4740BOOLEAN MlmeDlsReqSanity(
4741 IN PRTMP_ADAPTER pAd,
4742 IN VOID *Msg,
4743 IN ULONG MsgLen,
4744 OUT PRT_802_11_DLS *pDLS,
4745 OUT PUSHORT pReason);
4746
4747INT Set_DlsEntryInfo_Display_Proc(
4748 IN PRTMP_ADAPTER pAd,
4749 IN PUCHAR arg);
4750
4751MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
4752 IN PRTMP_ADAPTER pAd,
4753 IN PUCHAR pAddr,
4754 IN UINT DlsEntryIdx);
4755
4756BOOLEAN MacTableDeleteDlsEntry(
4757 IN PRTMP_ADAPTER pAd,
4758 IN USHORT wcid,
4759 IN PUCHAR pAddr);
4760
4761MAC_TABLE_ENTRY *DlsEntryTableLookup(
4762 IN PRTMP_ADAPTER pAd,
4763 IN PUCHAR pAddr,
4764 IN BOOLEAN bResetIdelCount);
4765
4766MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
4767 IN PRTMP_ADAPTER pAd,
4768 IN UCHAR wcid,
4769 IN PUCHAR pAddr,
4770 IN BOOLEAN bResetIdelCount);
4771
4772INT Set_DlsAddEntry_Proc(
4773 IN PRTMP_ADAPTER pAd,
4774 IN PUCHAR arg);
4775
4776INT Set_DlsTearDownEntry_Proc(
4777 IN PRTMP_ADAPTER pAd,
4778 IN PUCHAR arg);
4779#endif // QOS_DLS_SUPPORT //
4780#endif // CONFIG_STA_SUPPORT //
4781
4782#ifdef QOS_DLS_SUPPORT
4783BOOLEAN PeerDlsReqSanity(
4784 IN PRTMP_ADAPTER pAd,
4785 IN VOID *Msg,
4786 IN ULONG MsgLen,
4787 OUT PUCHAR pDA,
4788 OUT PUCHAR pSA,
4789 OUT USHORT *pCapabilityInfo,
4790 OUT USHORT *pDlsTimeout,
4791 OUT UCHAR *pRatesLen,
4792 OUT UCHAR Rates[],
4793 OUT UCHAR *pHtCapabilityLen,
4794 OUT HT_CAPABILITY_IE *pHtCapability);
4795
4796BOOLEAN PeerDlsRspSanity(
4797 IN PRTMP_ADAPTER pAd,
4798 IN VOID *Msg,
4799 IN ULONG MsgLen,
4800 OUT PUCHAR pDA,
4801 OUT PUCHAR pSA,
4802 OUT USHORT *pCapabilityInfo,
4803 OUT USHORT *pStatus,
4804 OUT UCHAR *pRatesLen,
4805 OUT UCHAR Rates[],
4806 OUT UCHAR *pHtCapabilityLen,
4807 OUT HT_CAPABILITY_IE *pHtCapability);
4808
4809BOOLEAN PeerDlsTearDownSanity(
4810 IN PRTMP_ADAPTER pAd,
4811 IN VOID *Msg,
4812 IN ULONG MsgLen,
4813 OUT PUCHAR pDA,
4814 OUT PUCHAR pSA,
4815 OUT USHORT *pReason);
4816#endif // QOS_DLS_SUPPORT //
4817
4818//======================================== 4645//========================================
4819 4646
4820VOID SyncStateMachineInit( 4647VOID SyncStateMachineInit(
@@ -4919,12 +4746,6 @@ VOID CntlWaitAssocProc(
4919 IN PRTMP_ADAPTER pAd, 4746 IN PRTMP_ADAPTER pAd,
4920 IN MLME_QUEUE_ELEM *Elem); 4747 IN MLME_QUEUE_ELEM *Elem);
4921 4748
4922#ifdef QOS_DLS_SUPPORT
4923VOID CntlOidDLSSetupProc(
4924 IN PRTMP_ADAPTER pAd,
4925 IN MLME_QUEUE_ELEM *Elem);
4926#endif // QOS_DLS_SUPPORT //
4927
4928VOID LinkUp( 4749VOID LinkUp(
4929 IN PRTMP_ADAPTER pAd, 4750 IN PRTMP_ADAPTER pAd,
4930 IN UCHAR BssType); 4751 IN UCHAR BssType);
diff --git a/drivers/staging/rt3070/rtmp_def.h b/drivers/staging/rt3070/rtmp_def.h
index 06f1d3ff504..6ba241b8c55 100644
--- a/drivers/staging/rt3070/rtmp_def.h
+++ b/drivers/staging/rt3070/rtmp_def.h
@@ -636,10 +636,6 @@
636 636
637 637
638 638
639#ifdef QOS_DLS_SUPPORT
640#define DLS_STATE_MACHINE 26
641#endif // QOS_DLS_SUPPORT //
642
643// 639//
644// STA's CONTROL/CONNECT state machine: states, events, total function # 640// STA's CONTROL/CONNECT state machine: states, events, total function #
645// 641//
diff --git a/drivers/staging/rt3070/sta/assoc.c b/drivers/staging/rt3070/sta/assoc.c
index 5c33a895bf7..8113b009eb0 100644
--- a/drivers/staging/rt3070/sta/assoc.c
+++ b/drivers/staging/rt3070/sta/assoc.c
@@ -948,36 +948,6 @@ VOID MlmeDisassocReqAction(
948 ULONG Timeout = 0; 948 ULONG Timeout = 0;
949 USHORT Status; 949 USHORT Status;
950 950
951#ifdef QOS_DLS_SUPPORT
952 // send DLS-TEAR_DOWN message,
953 if (pAd->CommonCfg.bDLSCapable)
954 {
955 UCHAR i;
956
957 // tear down local dls table entry
958 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
959 {
960 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
961 {
962 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
963 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
964 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
965 }
966 }
967
968 // tear down peer dls table entry
969 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
970 {
971 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
972 {
973 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
974 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
975 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
976 }
977 }
978 }
979#endif // QOS_DLS_SUPPORT //
980
981 // skip sanity check 951 // skip sanity check
982 pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg); 952 pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg);
983 953
diff --git a/drivers/staging/rt3070/sta/connect.c b/drivers/staging/rt3070/sta/connect.c
index f4aeee5ed15..d2bc22f9f54 100644
--- a/drivers/staging/rt3070/sta/connect.c
+++ b/drivers/staging/rt3070/sta/connect.c
@@ -288,12 +288,6 @@ VOID CntlIdleProc(
288 WpaMicFailureReportFrame(pAd, Elem); 288 WpaMicFailureReportFrame(pAd, Elem);
289 break; 289 break;
290 290
291#ifdef QOS_DLS_SUPPORT
292 case RT_OID_802_11_SET_DLS_PARAM:
293 CntlOidDLSSetupProc(pAd, Elem);
294 break;
295#endif // QOS_DLS_SUPPORT //
296
297 default: 291 default:
298 DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem->MsgType)); 292 DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",Elem->MsgType));
299 break; 293 break;
@@ -687,113 +681,6 @@ VOID CntlMlmeRoamingProc(
687 IterateOnBssTab(pAd); 681 IterateOnBssTab(pAd);
688} 682}
689 683
690#ifdef QOS_DLS_SUPPORT
691/*
692 ==========================================================================
693 Description:
694
695 IRQL = DISPATCH_LEVEL
696
697 ==========================================================================
698*/
699VOID CntlOidDLSSetupProc(
700 IN PRTMP_ADAPTER pAd,
701 IN MLME_QUEUE_ELEM *Elem)
702{
703 PRT_802_11_DLS pDLS = (PRT_802_11_DLS)Elem->Msg;
704 MLME_DLS_REQ_STRUCT MlmeDlsReq;
705 INT i;
706 USHORT reason = REASON_UNSPECIFY;
707
708 DBGPRINT(RT_DEBUG_TRACE,("CNTL - (OID set %02x:%02x:%02x:%02x:%02x:%02x with Valid=%d, Status=%d, TimeOut=%d, CountDownTimer=%d)\n",
709 pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5],
710 pDLS->Valid, pDLS->Status, pDLS->TimeOut, pDLS->CountDownTimer));
711
712 if (!pAd->CommonCfg.bDLSCapable)
713 return;
714
715 // DLS will not be supported when Adhoc mode
716 if (INFRA_ON(pAd))
717 {
718 for (i = 0; i < MAX_NUM_OF_DLS_ENTRY; i++)
719 {
720 if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
721 (pDLS->TimeOut == pAd->StaCfg.DLSEntry[i].TimeOut) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
722 {
723 // 1. Same setting, just drop it
724 DBGPRINT(RT_DEBUG_TRACE,("CNTL - setting unchanged\n"));
725 break;
726 }
727 else if (!pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
728 MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
729 {
730 // 2. Disable DLS link case, just tear down DLS link
731 reason = REASON_QOS_UNWANTED_MECHANISM;
732 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
733 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
734 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
735 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
736 DBGPRINT(RT_DEBUG_TRACE,("CNTL - start tear down procedure\n"));
737 break;
738 }
739 else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && !pAd->StaCfg.DLSEntry[i].Valid)
740 {
741 // 3. Enable case, start DLS setup procedure
742 NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
743
744 //Update countdown timer
745 pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
746 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
747 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
748 DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS setup case\n"));
749 break;
750 }
751 else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
752 (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && !MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
753 {
754 // 4. update mac case, tear down old DLS and setup new DLS
755 reason = REASON_QOS_UNWANTED_MECHANISM;
756 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
757 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
758 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
759 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
760 NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
761 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
762 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
763 DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS tear down and restart case\n"));
764 break;
765 }
766 else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
767 MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr) && (pAd->StaCfg.DLSEntry[i].TimeOut != pDLS->TimeOut))
768 {
769 // 5. update timeout case, start DLS setup procedure (no tear down)
770 pAd->StaCfg.DLSEntry[i].TimeOut = pDLS->TimeOut;
771 //Update countdown timer
772 pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
773 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
774 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
775 DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS update timeout case\n"));
776 break;
777 }
778 else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
779 (pAd->StaCfg.DLSEntry[i].Status != DLS_FINISH) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
780 {
781 // 6. re-setup case, start DLS setup procedure (no tear down)
782 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
783 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_REQ, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
784 DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS retry setup procedure\n"));
785 break;
786 }
787 else
788 {
789 DBGPRINT(RT_DEBUG_WARN,("CNTL - DLS not changed in entry - %d - Valid=%d, Status=%d, TimeOut=%d\n",
790 i, pAd->StaCfg.DLSEntry[i].Valid, pAd->StaCfg.DLSEntry[i].Status, pAd->StaCfg.DLSEntry[i].TimeOut));
791 }
792 }
793 }
794}
795#endif // QOS_DLS_SUPPORT //
796
797/* 684/*
798 ========================================================================== 685 ==========================================================================
799 Description: 686 Description:
@@ -2027,33 +1914,6 @@ VOID LinkDown(
2027 { 1914 {
2028 DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 2!!!\n")); 1915 DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN 2!!!\n"));
2029 1916
2030#ifdef QOS_DLS_SUPPORT
2031 // DLS tear down frame must be sent before link down
2032 // send DLS-TEAR_DOWN message
2033 if (pAd->CommonCfg.bDLSCapable)
2034 {
2035 // tear down local dls table entry
2036 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
2037 {
2038 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
2039 {
2040 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
2041 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
2042 }
2043 }
2044
2045 // tear down peer dls table entry
2046 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
2047 {
2048 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
2049 {
2050 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
2051 RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
2052 }
2053 }
2054 }
2055#endif // QOS_DLS_SUPPORT //
2056
2057 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON); 1917 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
2058 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); 1918 OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
2059 1919
@@ -2152,11 +2012,6 @@ VOID LinkDown(
2152 pAd->StaCfg.WpaState = SS_START; 2012 pAd->StaCfg.WpaState = SS_START;
2153 // Clear Replay counter 2013 // Clear Replay counter
2154 NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8); 2014 NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
2155
2156#ifdef QOS_DLS_SUPPORT
2157 if (pAd->CommonCfg.bDLSCapable)
2158 NdisZeroMemory(pAd->StaCfg.DlsReplayCounter, 8);
2159#endif // QOS_DLS_SUPPORT //
2160 } 2015 }
2161 2016
2162 2017
@@ -2476,26 +2331,6 @@ VOID ScanParmFill(
2476 ScanReq->ScanType = ScanType; 2331 ScanReq->ScanType = ScanType;
2477} 2332}
2478 2333
2479#ifdef QOS_DLS_SUPPORT
2480/*
2481 ==========================================================================
2482 Description:
2483
2484 IRQL = DISPATCH_LEVEL
2485
2486 ==========================================================================
2487*/
2488VOID DlsParmFill(
2489 IN PRTMP_ADAPTER pAd,
2490 IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
2491 IN PRT_802_11_DLS pDls,
2492 IN USHORT reason)
2493{
2494 pDlsReq->pDLS = pDls;
2495 pDlsReq->Reason = reason;
2496}
2497#endif // QOS_DLS_SUPPORT //
2498
2499/* 2334/*
2500 ========================================================================== 2335 ==========================================================================
2501 Description: 2336 Description:
diff --git a/drivers/staging/rt3070/sta/dls.c b/drivers/staging/rt3070/sta/dls.c
deleted file mode 100644
index 8bcd4132934..00000000000
--- a/drivers/staging/rt3070/sta/dls.c
+++ /dev/null
@@ -1,2170 +0,0 @@
1/*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
26
27 Module Name:
28 dls.c
29
30 Abstract:
31 Handle WMM-DLS state machine
32
33 Revision History:
34 Who When What
35 -------- ---------- ----------------------------------------------
36 Rory Chen 02-14-2006
37 Arvin Tai 06-03-2008 Modified for RT28xx
38 */
39
40#include "../rt_config.h"
41
42/*
43 ==========================================================================
44 Description:
45 dls state machine init, including state transition and timer init
46 Parameters:
47 Sm - pointer to the dls state machine
48 Note:
49 The state machine looks like this
50
51 DLS_IDLE
52 MT2_MLME_DLS_REQUEST MlmeDlsReqAction
53 MT2_PEER_DLS_REQUEST PeerDlsReqAction
54 MT2_PEER_DLS_RESPONSE PeerDlsRspAction
55 MT2_MLME_DLS_TEARDOWN MlmeTearDownAction
56 MT2_PEER_DLS_TEARDOWN PeerTearDownAction
57
58 IRQL = PASSIVE_LEVEL
59
60 ==========================================================================
61 */
62void DlsStateMachineInit(
63 IN PRTMP_ADAPTER pAd,
64 IN STATE_MACHINE *Sm,
65 OUT STATE_MACHINE_FUNC Trans[])
66{
67 UCHAR i;
68
69 StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_DLS_STATE, MAX_DLS_MSG, (STATE_MACHINE_FUNC)Drop, DLS_IDLE, DLS_MACHINE_BASE);
70
71 // the first column
72 StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_REQ, (STATE_MACHINE_FUNC)MlmeDlsReqAction);
73 StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_REQ, (STATE_MACHINE_FUNC)PeerDlsReqAction);
74 StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_RSP, (STATE_MACHINE_FUNC)PeerDlsRspAction);
75 StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)MlmeDlsTearDownAction);
76 StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_TEAR_DOWN, (STATE_MACHINE_FUNC)PeerDlsTearDownAction);
77
78 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
79 {
80 pAd->StaCfg.DLSEntry[i].pAd = pAd;
81 RTMPInitTimer(pAd, &pAd->StaCfg.DLSEntry[i].Timer, GET_TIMER_FUNCTION(DlsTimeoutAction), pAd, FALSE);
82 }
83}
84
85/*
86 ==========================================================================
87 Description:
88
89 IRQL = DISPATCH_LEVEL
90
91 ==========================================================================
92 */
93VOID MlmeDlsReqAction(
94 IN PRTMP_ADAPTER pAd,
95 IN MLME_QUEUE_ELEM *Elem)
96{
97 PUCHAR pOutBuffer = NULL;
98 NDIS_STATUS NStatus;
99 ULONG FrameLen = 0;
100 HEADER_802_11 DlsReqHdr;
101 PRT_802_11_DLS pDLS = NULL;
102 UCHAR Category = CATEGORY_DLS;
103 UCHAR Action = ACTION_DLS_REQUEST;
104 ULONG tmp;
105 USHORT reason;
106 ULONG Timeout;
107 BOOLEAN TimerCancelled;
108
109 if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &reason))
110 return;
111
112 DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsReqAction() \n"));
113
114 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
115 if (NStatus != NDIS_STATUS_SUCCESS)
116 {
117 DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsReqAction() allocate memory failed \n"));
118 return;
119 }
120
121 ActHeaderInit(pAd, &DlsReqHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
122
123 // Build basic frame first
124 MakeOutgoingFrame(pOutBuffer, &FrameLen,
125 sizeof(HEADER_802_11), &DlsReqHdr,
126 1, &Category,
127 1, &Action,
128 6, &pDLS->MacAddr,
129 6, pAd->CurrentAddress,
130 2, &pAd->StaActive.CapabilityInfo,
131 2, &pDLS->TimeOut,
132 1, &SupRateIe,
133 1, &pAd->MlmeAux.SupRateLen,
134 pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
135 END_OF_ARGS);
136
137 if (pAd->MlmeAux.ExtRateLen != 0)
138 {
139 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
140 1, &ExtRateIe,
141 1, &pAd->MlmeAux.ExtRateLen,
142 pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
143 END_OF_ARGS);
144 FrameLen += tmp;
145 }
146
147#ifdef DOT11_N_SUPPORT
148 if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
149 {
150 UCHAR HtLen;
151
152#ifdef RT_BIG_ENDIAN
153 HT_CAPABILITY_IE HtCapabilityTmp;
154#endif
155
156 // add HT Capability IE
157 HtLen = sizeof(HT_CAPABILITY_IE);
158#ifndef RT_BIG_ENDIAN
159 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
160 1, &HtCapIe,
161 1, &HtLen,
162 HtLen, &pAd->CommonCfg.HtCapability,
163 END_OF_ARGS);
164#else
165 NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
166 *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
167 *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
168
169 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
170 1, &HtCapIe,
171 1, &HtLen,
172 HtLen, &HtCapabilityTmp,
173 END_OF_ARGS);
174#endif
175 FrameLen = FrameLen + tmp;
176 }
177#endif // DOT11_N_SUPPORT //
178
179 RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
180 Timeout = DLS_TIMEOUT;
181 RTMPSetTimer(&pDLS->Timer, Timeout);
182
183 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
184 MlmeFreeMemory(pAd, pOutBuffer);
185}
186
187/*
188 ==========================================================================
189 Description:
190
191 IRQL = DISPATCH_LEVEL
192
193 ==========================================================================
194 */
195VOID PeerDlsReqAction(
196 IN PRTMP_ADAPTER pAd,
197 IN MLME_QUEUE_ELEM *Elem)
198{
199 PUCHAR pOutBuffer = NULL;
200 NDIS_STATUS NStatus;
201 ULONG FrameLen = 0;
202 USHORT StatusCode = MLME_SUCCESS;
203 HEADER_802_11 DlsRspHdr;
204 UCHAR Category = CATEGORY_DLS;
205 UCHAR Action = ACTION_DLS_RESPONSE;
206 ULONG tmp;
207 USHORT CapabilityInfo;
208 UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
209 USHORT DLSTimeOut;
210 SHORT i;
211 ULONG Timeout;
212 BOOLEAN TimerCancelled;
213 PRT_802_11_DLS pDLS = NULL;
214 UCHAR MaxSupportedRateIn500Kbps = 0;
215 UCHAR SupportedRatesLen;
216 UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
217 UCHAR HtCapabilityLen;
218 HT_CAPABILITY_IE HtCapability;
219
220 if (!PeerDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &DLSTimeOut,
221 &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
222 return;
223
224 // supported rates array may not be sorted. sort it and find the maximum rate
225 for (i = 0; i < SupportedRatesLen; i++)
226 {
227 if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
228 MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
229 }
230
231 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() from %02x:%02x:%02x:%02x:%02x:%02x\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
232
233 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
234 if (NStatus != NDIS_STATUS_SUCCESS)
235 {
236 DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() allocate memory failed \n"));
237 return;
238 }
239
240 if (!INFRA_ON(pAd))
241 {
242 StatusCode = MLME_REQUEST_DECLINED;
243 }
244 else if (!pAd->CommonCfg.bWmmCapable)
245 {
246 StatusCode = MLME_DEST_STA_IS_NOT_A_QSTA;
247 }
248 else if (!pAd->CommonCfg.bDLSCapable)
249 {
250 StatusCode = MLME_REQUEST_DECLINED;
251 }
252 else
253 {
254 // find table to update parameters
255 for (i = (MAX_NUM_OF_DLS_ENTRY-1); i >= 0; i--)
256 {
257 if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
258 {
259 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
260 pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
261 else
262 {
263 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
264 pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
265 }
266
267 pAd->StaCfg.DLSEntry[i].Sequence = 0;
268 pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
269 pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
270 if (HtCapabilityLen != 0)
271 pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
272 else
273 pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
274 pDLS = &pAd->StaCfg.DLSEntry[i];
275 break;
276 }
277 }
278
279 // can not find in table, create a new one
280 if (i < 0)
281 {
282 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() can not find same entry \n"));
283 for (i=(MAX_NUM_OF_DLS_ENTRY - 1); i >= MAX_NUM_OF_INIT_DLS_ENTRY; i--)
284 {
285 if (!pAd->StaCfg.DLSEntry[i].Valid)
286 {
287 MAC_TABLE_ENTRY *pEntry;
288 UCHAR MaxSupportedRate = RATE_11;
289
290 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
291 {
292 pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
293 }
294 else
295 {
296 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
297 pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
298 }
299
300 pAd->StaCfg.DLSEntry[i].Sequence = 0;
301 pAd->StaCfg.DLSEntry[i].Valid = TRUE;
302 pAd->StaCfg.DLSEntry[i].TimeOut = DLSTimeOut;
303 pAd->StaCfg.DLSEntry[i].CountDownTimer = DLSTimeOut;
304 NdisMoveMemory(pAd->StaCfg.DLSEntry[i].MacAddr, SA, MAC_ADDR_LEN);
305 if (HtCapabilityLen != 0)
306 pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
307 else
308 pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
309 pDLS = &pAd->StaCfg.DLSEntry[i];
310 pEntry = MacTableInsertDlsEntry(pAd, SA, i);
311
312 switch (MaxSupportedRateIn500Kbps)
313 {
314 case 108: MaxSupportedRate = RATE_54; break;
315 case 96: MaxSupportedRate = RATE_48; break;
316 case 72: MaxSupportedRate = RATE_36; break;
317 case 48: MaxSupportedRate = RATE_24; break;
318 case 36: MaxSupportedRate = RATE_18; break;
319 case 24: MaxSupportedRate = RATE_12; break;
320 case 18: MaxSupportedRate = RATE_9; break;
321 case 12: MaxSupportedRate = RATE_6; break;
322 case 22: MaxSupportedRate = RATE_11; break;
323 case 11: MaxSupportedRate = RATE_5_5; break;
324 case 4: MaxSupportedRate = RATE_2; break;
325 case 2: MaxSupportedRate = RATE_1; break;
326 default: MaxSupportedRate = RATE_11; break;
327 }
328
329 pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
330
331 if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
332 {
333 pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
334 pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
335 pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
336 pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
337 pEntry->HTPhyMode.field.MODE = MODE_CCK;
338 pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
339 }
340 else
341 {
342 pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
343 pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
344 pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
345 pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
346 pEntry->HTPhyMode.field.MODE = MODE_OFDM;
347 pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
348 }
349
350 pEntry->MaxHTPhyMode.field.BW = BW_20;
351 pEntry->MinHTPhyMode.field.BW = BW_20;
352
353#ifdef DOT11_N_SUPPORT
354 pEntry->HTCapability.MCSSet[0] = 0;
355 pEntry->HTCapability.MCSSet[1] = 0;
356
357 // If this Entry supports 802.11n, upgrade to HT rate.
358 if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
359 {
360 UCHAR j, bitmask; //k,bitmask;
361 CHAR ii;
362
363 if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
364 {
365 pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
366 }
367 else
368 {
369 pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
370 pAd->MacTab.fAnyStationNonGF = TRUE;
371 pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
372 }
373
374 if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
375 {
376 pEntry->MaxHTPhyMode.field.BW= BW_40;
377 pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
378 }
379 else
380 {
381 pEntry->MaxHTPhyMode.field.BW = BW_20;
382 pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
383 pAd->MacTab.fAnyStation20Only = TRUE;
384 }
385
386 // find max fixed rate
387 for (ii=15; ii>=0; ii--)
388 {
389 j = ii/8;
390 bitmask = (1<<(ii-(j*8)));
391 if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
392 {
393 pEntry->MaxHTPhyMode.field.MCS = ii;
394 break;
395 }
396 if (ii==0)
397 break;
398 }
399
400
401 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
402 {
403
404 printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
405 pAd->StaCfg.DesiredTransmitSetting.field.MCS);
406 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
407 {
408 // Fix MCS as HT Duplicated Mode
409 pEntry->MaxHTPhyMode.field.BW = 1;
410 pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
411 pEntry->MaxHTPhyMode.field.STBC = 0;
412 pEntry->MaxHTPhyMode.field.ShortGI = 0;
413 pEntry->MaxHTPhyMode.field.MCS = 32;
414 }
415 else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
416 {
417 // STA supports fixed MCS
418 pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
419 }
420 }
421
422 pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
423 pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
424 pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
425 pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
426 pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
427 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
428
429 if (HtCapability.HtCapInfo.ShortGIfor20)
430 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
431 if (HtCapability.HtCapInfo.ShortGIfor40)
432 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
433 if (HtCapability.HtCapInfo.TxSTBC)
434 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
435 if (HtCapability.HtCapInfo.RxSTBC)
436 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
437 if (HtCapability.ExtHtCapInfo.PlusHTC)
438 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
439 if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
440 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
441 if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
442 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
443
444 NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
445 }
446#endif // DOT11_N_SUPPORT //
447
448 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
449 pEntry->CurrTxRate = pEntry->MaxSupportedRate;
450 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
451
452 if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
453 {
454 PUCHAR pTable;
455 UCHAR TableSize = 0;
456
457 MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
458 pEntry->bAutoTxRateSwitch = TRUE;
459 }
460 else
461 {
462 pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
463 pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
464 pEntry->bAutoTxRateSwitch = FALSE;
465
466 RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
467 }
468 pEntry->RateLen = SupportedRatesLen;
469
470 break;
471 }
472 }
473 }
474 StatusCode = MLME_SUCCESS;
475
476 // can not find in table, create a new one
477 if (i < 0)
478 {
479 StatusCode = MLME_QOS_UNSPECIFY;
480 DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() DLSEntry table full(only can support %d DLS session) \n", MAX_NUM_OF_DLS_ENTRY - MAX_NUM_OF_INIT_DLS_ENTRY));
481 }
482 else
483 {
484 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() use entry(%d) %02x:%02x:%02x:%02x:%02x:%02x\n",
485 i, SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
486 }
487 }
488
489 ActHeaderInit(pAd, &DlsRspHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
490
491 // Build basic frame first
492 if (StatusCode == MLME_SUCCESS)
493 {
494 MakeOutgoingFrame(pOutBuffer, &FrameLen,
495 sizeof(HEADER_802_11), &DlsRspHdr,
496 1, &Category,
497 1, &Action,
498 2, &StatusCode,
499 6, SA,
500 6, pAd->CurrentAddress,
501 2, &pAd->StaActive.CapabilityInfo,
502 1, &SupRateIe,
503 1, &pAd->MlmeAux.SupRateLen,
504 pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
505 END_OF_ARGS);
506
507 if (pAd->MlmeAux.ExtRateLen != 0)
508 {
509 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
510 1, &ExtRateIe,
511 1, &pAd->MlmeAux.ExtRateLen,
512 pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
513 END_OF_ARGS);
514 FrameLen += tmp;
515 }
516
517#ifdef DOT11_N_SUPPORT
518 if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
519 {
520 UCHAR HtLen;
521
522#ifdef RT_BIG_ENDIAN
523 HT_CAPABILITY_IE HtCapabilityTmp;
524#endif
525
526 // add HT Capability IE
527 HtLen = sizeof(HT_CAPABILITY_IE);
528#ifndef RT_BIG_ENDIAN
529 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
530 1, &HtCapIe,
531 1, &HtLen,
532 HtLen, &pAd->CommonCfg.HtCapability,
533 END_OF_ARGS);
534#else
535 NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
536 *(USHORT *)(&HtCapabilityTmp.HtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.HtCapInfo));
537 *(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo) = SWAP16(*(USHORT *)(&HtCapabilityTmp.ExtHtCapInfo));
538
539 MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
540 1, &HtCapIe,
541 1, &HtLen,
542 HtLen, &HtCapabilityTmp,
543 END_OF_ARGS);
544#endif
545 FrameLen = FrameLen + tmp;
546 }
547#endif // DOT11_N_SUPPORT //
548
549 if (pDLS && (pDLS->Status != DLS_FINISH))
550 {
551 RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
552 Timeout = DLS_TIMEOUT;
553 RTMPSetTimer(&pDLS->Timer, Timeout);
554 }
555 }
556 else
557 {
558 MakeOutgoingFrame(pOutBuffer, &FrameLen,
559 sizeof(HEADER_802_11), &DlsRspHdr,
560 1, &Category,
561 1, &Action,
562 2, &StatusCode,
563 6, SA,
564 6, pAd->CurrentAddress,
565 END_OF_ARGS);
566 }
567
568 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
569 MlmeFreeMemory(pAd, pOutBuffer);
570}
571
572/*
573 ==========================================================================
574 Description:
575
576 IRQL = DISPATCH_LEVEL
577
578 ==========================================================================
579 */
580VOID PeerDlsRspAction(
581 IN PRTMP_ADAPTER pAd,
582 IN MLME_QUEUE_ELEM *Elem)
583{
584 USHORT CapabilityInfo;
585 UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
586 USHORT StatusCode;
587 SHORT i;
588 BOOLEAN TimerCancelled;
589 UCHAR MaxSupportedRateIn500Kbps = 0;
590 UCHAR SupportedRatesLen;
591 UCHAR SupportedRates[MAX_LEN_OF_SUPPORTED_RATES];
592 UCHAR HtCapabilityLen;
593 HT_CAPABILITY_IE HtCapability;
594
595 if (!pAd->CommonCfg.bDLSCapable)
596 return;
597
598 if (!INFRA_ON(pAd))
599 return;
600
601 if (!PeerDlsRspSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &StatusCode,
602 &SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
603 return;
604
605 // supported rates array may not be sorted. sort it and find the maximum rate
606 for (i=0; i<SupportedRatesLen; i++)
607 {
608 if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
609 MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
610 }
611
612 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x with StatusCode=%d, CapabilityInfo=0x%x\n",
613 SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], StatusCode, CapabilityInfo));
614
615 for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
616 {
617 if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
618 {
619 if (StatusCode == MLME_SUCCESS)
620 {
621 MAC_TABLE_ENTRY *pEntry;
622 UCHAR MaxSupportedRate = RATE_11;
623
624 pEntry = MacTableInsertDlsEntry(pAd, SA, i);
625
626 switch (MaxSupportedRateIn500Kbps)
627 {
628 case 108: MaxSupportedRate = RATE_54; break;
629 case 96: MaxSupportedRate = RATE_48; break;
630 case 72: MaxSupportedRate = RATE_36; break;
631 case 48: MaxSupportedRate = RATE_24; break;
632 case 36: MaxSupportedRate = RATE_18; break;
633 case 24: MaxSupportedRate = RATE_12; break;
634 case 18: MaxSupportedRate = RATE_9; break;
635 case 12: MaxSupportedRate = RATE_6; break;
636 case 22: MaxSupportedRate = RATE_11; break;
637 case 11: MaxSupportedRate = RATE_5_5; break;
638 case 4: MaxSupportedRate = RATE_2; break;
639 case 2: MaxSupportedRate = RATE_1; break;
640 default: MaxSupportedRate = RATE_11; break;
641 }
642
643 pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
644
645 if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
646 {
647 pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
648 pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
649 pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
650 pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
651 pEntry->HTPhyMode.field.MODE = MODE_CCK;
652 pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
653 }
654 else
655 {
656 pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
657 pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
658 pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
659 pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
660 pEntry->HTPhyMode.field.MODE = MODE_OFDM;
661 pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
662 }
663
664 pEntry->MaxHTPhyMode.field.BW = BW_20;
665 pEntry->MinHTPhyMode.field.BW = BW_20;
666
667#ifdef DOT11_N_SUPPORT
668 pEntry->HTCapability.MCSSet[0] = 0;
669 pEntry->HTCapability.MCSSet[1] = 0;
670
671 // If this Entry supports 802.11n, upgrade to HT rate.
672 if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
673 {
674 UCHAR j, bitmask; //k,bitmask;
675 CHAR ii;
676
677 if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
678 {
679 pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
680 }
681 else
682 {
683 pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
684 pAd->MacTab.fAnyStationNonGF = TRUE;
685 pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
686 }
687
688 if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
689 {
690 pEntry->MaxHTPhyMode.field.BW= BW_40;
691 pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
692 }
693 else
694 {
695 pEntry->MaxHTPhyMode.field.BW = BW_20;
696 pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
697 pAd->MacTab.fAnyStation20Only = TRUE;
698 }
699
700 // find max fixed rate
701 for (ii=15; ii>=0; ii--)
702 {
703 j = ii/8;
704 bitmask = (1<<(ii-(j*8)));
705 if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
706 {
707 pEntry->MaxHTPhyMode.field.MCS = ii;
708 break;
709 }
710 if (ii==0)
711 break;
712 }
713
714 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
715 {
716 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
717 {
718 // Fix MCS as HT Duplicated Mode
719 pEntry->MaxHTPhyMode.field.BW = 1;
720 pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
721 pEntry->MaxHTPhyMode.field.STBC = 0;
722 pEntry->MaxHTPhyMode.field.ShortGI = 0;
723 pEntry->MaxHTPhyMode.field.MCS = 32;
724 }
725 else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
726 {
727 // STA supports fixed MCS
728 pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
729 }
730 }
731
732 pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
733 pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
734 pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
735 pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
736 pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
737 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
738
739 if (HtCapability.HtCapInfo.ShortGIfor20)
740 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
741 if (HtCapability.HtCapInfo.ShortGIfor40)
742 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
743 if (HtCapability.HtCapInfo.TxSTBC)
744 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
745 if (HtCapability.HtCapInfo.RxSTBC)
746 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
747 if (HtCapability.ExtHtCapInfo.PlusHTC)
748 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
749 if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
750 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
751 if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
752 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
753
754 NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
755 }
756#endif // DOT11_N_SUPPORT //
757 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
758 pEntry->CurrTxRate = pEntry->MaxSupportedRate;
759 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
760
761 if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
762 {
763 PUCHAR pTable;
764 UCHAR TableSize = 0;
765
766 MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
767 pEntry->bAutoTxRateSwitch = TRUE;
768 }
769 else
770 {
771 pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
772 pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
773 pEntry->bAutoTxRateSwitch = FALSE;
774
775 RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
776 }
777 pEntry->RateLen = SupportedRatesLen;
778
779 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
780 {
781 // If support WPA or WPA2, start STAKey hand shake,
782 // If failed hand shake, just tear down peer DLS
783 if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
784 {
785 MLME_DLS_REQ_STRUCT MlmeDlsReq;
786 USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
787
788 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
789 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
790 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
791 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
792 DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
793 }
794 else
795 {
796 pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
797 DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
798 }
799 }
800 else
801 {
802 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
803 pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
804 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
805 }
806
807 //initialize seq no for DLS frames.
808 pAd->StaCfg.DLSEntry[i].Sequence = 0;
809 if (HtCapabilityLen != 0)
810 pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
811 else
812 pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
813 }
814 else
815 {
816 // DLS setup procedure failed.
817 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
818 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
819 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
820 DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
821 }
822 }
823 }
824
825 if (i >= MAX_NUM_OF_INIT_DLS_ENTRY)
826 {
827 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() update timeout value \n"));
828 for (i=(MAX_NUM_OF_DLS_ENTRY-1); i>=MAX_NUM_OF_INIT_DLS_ENTRY; i--)
829 {
830 if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
831 {
832 if (StatusCode == MLME_SUCCESS)
833 {
834 MAC_TABLE_ENTRY *pEntry;
835 UCHAR MaxSupportedRate = RATE_11;
836
837 pEntry = MacTableInsertDlsEntry(pAd, SA, i);
838
839 switch (MaxSupportedRateIn500Kbps)
840 {
841 case 108: MaxSupportedRate = RATE_54; break;
842 case 96: MaxSupportedRate = RATE_48; break;
843 case 72: MaxSupportedRate = RATE_36; break;
844 case 48: MaxSupportedRate = RATE_24; break;
845 case 36: MaxSupportedRate = RATE_18; break;
846 case 24: MaxSupportedRate = RATE_12; break;
847 case 18: MaxSupportedRate = RATE_9; break;
848 case 12: MaxSupportedRate = RATE_6; break;
849 case 22: MaxSupportedRate = RATE_11; break;
850 case 11: MaxSupportedRate = RATE_5_5; break;
851 case 4: MaxSupportedRate = RATE_2; break;
852 case 2: MaxSupportedRate = RATE_1; break;
853 default: MaxSupportedRate = RATE_11; break;
854 }
855
856 pEntry->MaxSupportedRate = min(pAd->CommonCfg.MaxTxRate, MaxSupportedRate);
857
858 if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
859 {
860 pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
861 pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
862 pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
863 pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
864 pEntry->HTPhyMode.field.MODE = MODE_CCK;
865 pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
866 }
867 else
868 {
869 pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
870 pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
871 pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
872 pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
873 pEntry->HTPhyMode.field.MODE = MODE_OFDM;
874 pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
875 }
876
877 pEntry->MaxHTPhyMode.field.BW = BW_20;
878 pEntry->MinHTPhyMode.field.BW = BW_20;
879
880#ifdef DOT11_N_SUPPORT
881 pEntry->HTCapability.MCSSet[0] = 0;
882 pEntry->HTCapability.MCSSet[1] = 0;
883
884 // If this Entry supports 802.11n, upgrade to HT rate.
885 if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
886 {
887 UCHAR j, bitmask; //k,bitmask;
888 CHAR ii;
889
890 if ((HtCapability.HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
891 {
892 pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
893 }
894 else
895 {
896 pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
897 pAd->MacTab.fAnyStationNonGF = TRUE;
898 pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
899 }
900
901 if ((HtCapability.HtCapInfo.ChannelWidth) && (pAd->CommonCfg.DesiredHtPhy.ChannelWidth))
902 {
903 pEntry->MaxHTPhyMode.field.BW= BW_40;
904 pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
905 }
906 else
907 {
908 pEntry->MaxHTPhyMode.field.BW = BW_20;
909 pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
910 pAd->MacTab.fAnyStation20Only = TRUE;
911 }
912
913 // find max fixed rate
914 for (ii=15; ii>=0; ii--)
915 {
916 j = ii/8;
917 bitmask = (1<<(ii-(j*8)));
918 if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
919 {
920 pEntry->MaxHTPhyMode.field.MCS = ii;
921 break;
922 }
923 if (ii==0)
924 break;
925 }
926
927 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
928 {
929 printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
930 pAd->StaCfg.DesiredTransmitSetting.field.MCS);
931 if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
932 {
933 // Fix MCS as HT Duplicated Mode
934 pEntry->MaxHTPhyMode.field.BW = 1;
935 pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
936 pEntry->MaxHTPhyMode.field.STBC = 0;
937 pEntry->MaxHTPhyMode.field.ShortGI = 0;
938 pEntry->MaxHTPhyMode.field.MCS = 32;
939 }
940 else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
941 {
942 // STA supports fixed MCS
943 pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
944 }
945 }
946
947 pEntry->MaxHTPhyMode.field.STBC = (HtCapability.HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
948 pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
949 pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
950 pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
951 pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
952 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
953
954 if (HtCapability.HtCapInfo.ShortGIfor20)
955 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
956 if (HtCapability.HtCapInfo.ShortGIfor40)
957 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
958 if (HtCapability.HtCapInfo.TxSTBC)
959 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
960 if (HtCapability.HtCapInfo.RxSTBC)
961 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
962 if (HtCapability.ExtHtCapInfo.PlusHTC)
963 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
964 if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
965 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
966 if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
967 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
968
969 NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
970 }
971#endif // DOT11_N_SUPPORT //
972
973 pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
974 pEntry->CurrTxRate = pEntry->MaxSupportedRate;
975 CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
976
977 if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
978 {
979 PUCHAR pTable;
980 UCHAR TableSize = 0;
981
982 MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
983 pEntry->bAutoTxRateSwitch = TRUE;
984 }
985 else
986 {
987 pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
988 pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
989 pEntry->bAutoTxRateSwitch = FALSE;
990
991 RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
992 }
993 pEntry->RateLen = SupportedRatesLen;
994
995 if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
996 {
997 // If support WPA or WPA2, start STAKey hand shake,
998 // If failed hand shake, just tear down peer DLS
999 if (RTMPSendSTAKeyRequest(pAd, pAd->StaCfg.DLSEntry[i].MacAddr) != NDIS_STATUS_SUCCESS)
1000 {
1001 MLME_DLS_REQ_STRUCT MlmeDlsReq;
1002 USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
1003
1004 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
1005 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
1006 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1007 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1008 DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed when call RTMPSendSTAKeyRequest \n"));
1009 }
1010 else
1011 {
1012 pAd->StaCfg.DLSEntry[i].Status = DLS_WAIT_KEY;
1013 DBGPRINT(RT_DEBUG_TRACE,("DLS - waiting for STAKey handshake procedure\n"));
1014 }
1015 }
1016 else
1017 {
1018 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
1019 pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
1020 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsRspAction() from %02x:%02x:%02x:%02x:%02x:%02x Succeed with WEP or no security\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
1021 }
1022 pAd->StaCfg.DLSEntry[i].Sequence = 0;
1023 if (HtCapabilityLen != 0)
1024 pAd->StaCfg.DLSEntry[i].bHTCap = TRUE;
1025 else
1026 pAd->StaCfg.DLSEntry[i].bHTCap = FALSE;
1027 }
1028 else
1029 {
1030 // DLS setup procedure failed.
1031 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1032 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1033 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
1034 DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsRspAction failed with StatusCode=%d \n", StatusCode));
1035 }
1036 }
1037 }
1038 }
1039}
1040
1041/*
1042 ==========================================================================
1043 Description:
1044
1045 IRQL = DISPATCH_LEVEL
1046
1047 ==========================================================================
1048 */
1049VOID MlmeDlsTearDownAction(
1050 IN PRTMP_ADAPTER pAd,
1051 IN MLME_QUEUE_ELEM *Elem)
1052{
1053 PUCHAR pOutBuffer = NULL;
1054 NDIS_STATUS NStatus;
1055 ULONG FrameLen = 0;
1056 UCHAR Category = CATEGORY_DLS;
1057 UCHAR Action = ACTION_DLS_TEARDOWN;
1058 USHORT ReasonCode = REASON_QOS_UNSPECIFY;
1059 HEADER_802_11 DlsTearDownHdr;
1060 PRT_802_11_DLS pDLS;
1061 BOOLEAN TimerCancelled;
1062 UCHAR i;
1063
1064 if(!MlmeDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, &pDLS, &ReasonCode))
1065 return;
1066
1067 DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsTearDownAction() with ReasonCode=%d \n", ReasonCode));
1068
1069 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
1070 if (NStatus != NDIS_STATUS_SUCCESS)
1071 {
1072 DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsTearDownAction() allocate memory failed \n"));
1073 return;
1074 }
1075
1076 ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
1077
1078 // Build basic frame first
1079 MakeOutgoingFrame(pOutBuffer, &FrameLen,
1080 sizeof(HEADER_802_11), &DlsTearDownHdr,
1081 1, &Category,
1082 1, &Action,
1083 6, &pDLS->MacAddr,
1084 6, pAd->CurrentAddress,
1085 2, &ReasonCode,
1086 END_OF_ARGS);
1087
1088 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
1089 MlmeFreeMemory(pAd, pOutBuffer);
1090 RTMPCancelTimer(&pDLS->Timer, &TimerCancelled);
1091
1092 // Remove key in local dls table entry
1093 for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
1094 {
1095 if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
1096 {
1097 MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
1098 }
1099 }
1100
1101 // clear peer dls table entry
1102 for (i = MAX_NUM_OF_INIT_DLS_ENTRY; i < MAX_NUM_OF_DLS_ENTRY; i++)
1103 {
1104 if (MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
1105 {
1106 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1107 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1108 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
1109 MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
1110 }
1111 }
1112}
1113
1114/*
1115 ==========================================================================
1116 Description:
1117
1118 IRQL = DISPATCH_LEVEL
1119
1120 ==========================================================================
1121 */
1122VOID PeerDlsTearDownAction(
1123 IN PRTMP_ADAPTER pAd,
1124 IN MLME_QUEUE_ELEM *Elem)
1125{
1126 UCHAR DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
1127 USHORT ReasonCode;
1128 UINT i;
1129 BOOLEAN TimerCancelled;
1130
1131 if (!pAd->CommonCfg.bDLSCapable)
1132 return;
1133
1134 if (!INFRA_ON(pAd))
1135 return;
1136
1137 if (!PeerDlsTearDownSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &ReasonCode))
1138 return;
1139
1140 DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsTearDownAction() from %02x:%02x:%02x:%02x:%02x:%02x with ReasonCode=%d\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], ReasonCode));
1141
1142 // clear local dls table entry
1143 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
1144 {
1145 if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
1146 {
1147 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1148 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1149 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
1150 //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
1151 //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
1152 MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
1153 }
1154 }
1155
1156 // clear peer dls table entry
1157 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
1158 {
1159 if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(SA, pAd->StaCfg.DLSEntry[i].MacAddr))
1160 {
1161 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1162 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1163 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
1164 //AsicDelWcidTab(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
1165 //AsicRemovePairwiseKeyEntry(pAd, BSS0, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID);
1166 MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
1167 }
1168 }
1169}
1170
1171/*
1172 ==========================================================================
1173 Description:
1174
1175 IRQL = DISPATCH_LEVEL
1176
1177 ==========================================================================
1178 */
1179VOID RTMPCheckDLSTimeOut(
1180 IN PRTMP_ADAPTER pAd)
1181{
1182 ULONG i;
1183 MLME_DLS_REQ_STRUCT MlmeDlsReq;
1184 USHORT reason = REASON_QOS_UNSPECIFY;
1185
1186 if (! pAd->CommonCfg.bDLSCapable)
1187 return;
1188
1189 if (! INFRA_ON(pAd))
1190 return;
1191
1192 // If timeout value is equaled to zero, it means always not be timeout.
1193
1194 // update local dls table entry
1195 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
1196 {
1197 if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
1198 && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
1199 {
1200 pAd->StaCfg.DLSEntry[i].CountDownTimer --;
1201
1202 if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
1203 {
1204 reason = REASON_QOS_REQUEST_TIMEOUT;
1205 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1206 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1207 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
1208 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
1209 }
1210 }
1211 }
1212
1213 // update peer dls table entry
1214 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
1215 {
1216 if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
1217 && (pAd->StaCfg.DLSEntry[i].TimeOut != 0))
1218 {
1219 pAd->StaCfg.DLSEntry[i].CountDownTimer --;
1220
1221 if (pAd->StaCfg.DLSEntry[i].CountDownTimer == 0)
1222 {
1223 reason = REASON_QOS_REQUEST_TIMEOUT;
1224 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1225 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1226 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
1227 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
1228 }
1229 }
1230 }
1231}
1232
1233/*
1234 ==========================================================================
1235 Description:
1236
1237 IRQL = DISPATCH_LEVEL
1238
1239 ==========================================================================
1240 */
1241BOOLEAN RTMPRcvFrameDLSCheck(
1242 IN PRTMP_ADAPTER pAd,
1243 IN PHEADER_802_11 pHeader,
1244 IN ULONG Len,
1245 IN PRT28XX_RXD_STRUC pRxD)
1246{
1247 ULONG i;
1248 BOOLEAN bFindEntry = FALSE;
1249 BOOLEAN bSTAKeyFrame = FALSE;
1250 PEAPOL_PACKET pEap;
1251 PUCHAR pProto, pAddr = NULL;
1252 PUCHAR pSTAKey = NULL;
1253 UCHAR ZeroReplay[LEN_KEY_DESC_REPLAY];
1254 UCHAR Mic[16], OldMic[16];
1255 UCHAR digest[80];
1256 UCHAR DlsPTK[80];
1257 UCHAR temp[64];
1258 BOOLEAN TimerCancelled;
1259 CIPHER_KEY PairwiseKey;
1260
1261
1262 if (! pAd->CommonCfg.bDLSCapable)
1263 return bSTAKeyFrame;
1264
1265 if (! INFRA_ON(pAd))
1266 return bSTAKeyFrame;
1267
1268 if (! (pHeader->FC.SubType & 0x08))
1269 return bSTAKeyFrame;
1270
1271 if (Len < LENGTH_802_11 + 6 + 2 + 2)
1272 return bSTAKeyFrame;
1273
1274 pProto = (PUCHAR)pHeader + LENGTH_802_11 + 2 + 6; // QOS Control field , 0xAA 0xAA 0xAA 0x00 0x00 0x00
1275 pAddr = pHeader->Addr2;
1276
1277 // L2PAD bit on will pad 2 bytes at LLC
1278 if (pRxD->L2PAD)
1279 {
1280 pProto += 2;
1281 }
1282
1283 if (RTMPEqualMemory(EAPOL, pProto, 2) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
1284 {
1285 pEap = (PEAPOL_PACKET) (pProto + 2);
1286
1287 DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff Len=%ld, DataLen=%d, KeyMic=%d, Install=%d, KeyAck=%d, Secure=%d, EKD_DL=%d, Error=%d, Request=%d\n", Len,
1288 (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16),
1289 pEap->KeyDesc.KeyInfo.KeyMic,
1290 pEap->KeyDesc.KeyInfo.Install,
1291 pEap->KeyDesc.KeyInfo.KeyAck,
1292 pEap->KeyDesc.KeyInfo.Secure,
1293 pEap->KeyDesc.KeyInfo.EKD_DL,
1294 pEap->KeyDesc.KeyInfo.Error,
1295 pEap->KeyDesc.KeyInfo.Request));
1296
1297 if ((Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE + 16)) && pEap->KeyDesc.KeyInfo.KeyMic
1298 && pEap->KeyDesc.KeyInfo.Install && pEap->KeyDesc.KeyInfo.KeyAck && pEap->KeyDesc.KeyInfo.Secure
1299 && pEap->KeyDesc.KeyInfo.EKD_DL && !pEap->KeyDesc.KeyInfo.Error && !pEap->KeyDesc.KeyInfo.Request)
1300 {
1301 // First validate replay counter, only accept message with larger replay counter
1302 // Let equal pass, some AP start with all zero replay counter
1303 NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
1304 if ((RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY) != 1) &&
1305 (RTMPCompareMemory(pEap->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
1306 return bSTAKeyFrame;
1307
1308 //RTMPMoveMemory(pAd->StaCfg.ReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
1309 RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
1310 DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter (%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
1311 pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
1312 pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
1313 pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
1314
1315 // put these code segment to get the replay counter
1316 if (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
1317 return bSTAKeyFrame;
1318
1319 // Check MIC value
1320 // Save the MIC and replace with zero
1321 // use proprietary PTK
1322 NdisZeroMemory(temp, 64);
1323 NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
1324 WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
1325
1326 NdisMoveMemory(OldMic, pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
1327 NdisZeroMemory(pEap->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
1328 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
1329 {
1330 // AES
1331 HMAC_SHA1((PUCHAR) pEap, pEap->Body_Len[1] + 4, DlsPTK, LEN_EAP_MICK, digest);
1332 NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
1333 }
1334 else
1335 {
1336 hmac_md5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic);
1337 }
1338
1339 if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
1340 {
1341 DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in Msg1 of STAKey handshake! \n"));
1342 return bSTAKeyFrame;
1343 }
1344 else
1345 DBGPRINT(RT_DEBUG_TRACE, ("MIC VALID in Msg1 of STAKey handshake! \n"));
1346#if 1
1347 if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0C)
1348 && (pEap->KeyDesc.KeyData[4] == 0x43) && (pEap->KeyDesc.KeyData[5] == 0x02))
1349 {
1350 pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
1351 pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
1352
1353 DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%ld, KeyDataLen=%d\n",
1354 pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
1355
1356 bSTAKeyFrame = TRUE;
1357 }
1358#else
1359 if ((pEap->KeyDesc.KeyData[0] == 0xDD) && (pEap->KeyDesc.KeyData[2] == 0x00) && (pEap->KeyDesc.KeyData[3] == 0x0F)
1360 && (pEap->KeyDesc.KeyData[4] == 0xAC) && (pEap->KeyDesc.KeyData[5] == 0x02))
1361 {
1362 pAddr = pEap->KeyDesc.KeyData + 8; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2)
1363 pSTAKey = pEap->KeyDesc.KeyData + 14; // Tpe(1), Len(1), OUI(3), DataType(1), Reserved(2), STAKey_Mac_Addr(6)
1364
1365 DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 from %02x:%02x:%02x:%02x:%02x:%02x Len=%d, KeyDataLen=%d\n",
1366 pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], Len, pEap->KeyDesc.KeyData[1]));
1367
1368 bSTAKeyFrame = TRUE;
1369 }
1370#endif
1371
1372 }
1373 else if (Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE))
1374 {
1375 RTMPMoveMemory(pAd->StaCfg.DlsReplayCounter, pEap->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
1376 DBGPRINT(RT_DEBUG_TRACE,("DLS - Sniff replay counter 2(%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x) Len=%ld, KeyDataLen=%d\n",
1377 pAd->StaCfg.ReplayCounter[0], pAd->StaCfg.ReplayCounter[1], pAd->StaCfg.ReplayCounter[2],
1378 pAd->StaCfg.ReplayCounter[3], pAd->StaCfg.ReplayCounter[4], pAd->StaCfg.ReplayCounter[5],
1379 pAd->StaCfg.ReplayCounter[6], pAd->StaCfg.ReplayCounter[7], Len, pEap->KeyDesc.KeyData[1]));
1380
1381 }
1382 }
1383
1384 // If timeout value is equaled to zero, it means always not be timeout.
1385 // update local dls table entry
1386 for (i= 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
1387 {
1388 if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
1389 {
1390 if (bSTAKeyFrame)
1391 {
1392 PMAC_TABLE_ENTRY pEntry;
1393
1394 // STAKey frame, add pairwise key table
1395 pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
1396 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
1397
1398 PairwiseKey.KeyLen = LEN_TKIP_EK;
1399 NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
1400 NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
1401 NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
1402
1403 PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
1404
1405 pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
1406 //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
1407 //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
1408 // Add Pair-wise key to Asic
1409#ifdef RT2870
1410//Benson modified for USB interface, avoid in interrupt when write key, 20080724 -->
1411 {
1412 RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
1413 COPY_MAC_ADDR(KeyInfo.MacAddr,pAd->StaCfg.DLSEntry[i].MacAddr);
1414 KeyInfo.MacTabMatchWCID=pAd->StaCfg.DLSEntry[i].MacTabMatchWCID;
1415 NdisMoveMemory(&KeyInfo.CipherKey, &PairwiseKey,sizeof(CIPHER_KEY));
1416 RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_KEY_TABLE, &KeyInfo, sizeof(RT_ADD_PAIRWISE_KEY_ENTRY));
1417 }
1418 {
1419 PMAC_TABLE_ENTRY pDLSEntry;
1420 pDLSEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
1421 pDLSEntry->PairwiseKey.CipherAlg=PairwiseKey.CipherAlg;
1422 RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_RX_WCID_TABLE, pDLSEntry, sizeof(MAC_TABLE_ENTRY));
1423 }
1424//Benson modified for USB interface, avoid in interrupt when write key, 20080724 <--
1425#endif // RT2870 //
1426 NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
1427 DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Peer STA MAC Address STAKey) \n"));
1428
1429 RTMPSendSTAKeyHandShake(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
1430
1431 DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Initiator side)\n"));
1432 }
1433 else
1434 {
1435 // Data frame, update timeout value
1436 if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
1437 {
1438 pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
1439 //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
1440 }
1441 }
1442
1443 bFindEntry = TRUE;
1444 }
1445 }
1446
1447 // update peer dls table entry
1448 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
1449 {
1450 if (pAd->StaCfg.DLSEntry[i].Valid && MAC_ADDR_EQUAL(pAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
1451 {
1452 if (bSTAKeyFrame)
1453 {
1454 PMAC_TABLE_ENTRY pEntry = NULL;
1455
1456 // STAKey frame, add pairwise key table, and send STAkey Msg-2
1457 pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
1458 RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
1459
1460 PairwiseKey.KeyLen = LEN_TKIP_EK;
1461 NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
1462 NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
1463 NdisMoveMemory(PairwiseKey.RxMic, &pSTAKey[24], LEN_TKIP_TXMICK);
1464
1465 PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg;
1466
1467 pEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
1468 //AsicAddKeyEntry(pAd, (USHORT)(i + 2), BSS0, 0, &PairwiseKey, TRUE, TRUE); // reserve 0 for multicast, 1 for unicast
1469 //AsicUpdateRxWCIDTable(pAd, (USHORT)(i + 2), pAddr);
1470 // Add Pair-wise key to Asic
1471#ifdef RT2870
1472//Benson modified for USB interface, avoid in interrupt when write key, 20080724 -->
1473 {
1474 RT_ADD_PAIRWISE_KEY_ENTRY KeyInfo;
1475 COPY_MAC_ADDR(KeyInfo.MacAddr,pAd->StaCfg.DLSEntry[i].MacAddr);
1476 KeyInfo.MacTabMatchWCID=pAd->StaCfg.DLSEntry[i].MacTabMatchWCID;
1477 NdisMoveMemory(&KeyInfo.CipherKey, &PairwiseKey,sizeof(CIPHER_KEY));
1478 RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_KEY_TABLE, &KeyInfo, sizeof(RT_ADD_PAIRWISE_KEY_ENTRY));
1479 }
1480 {
1481 PMAC_TABLE_ENTRY pDLSEntry;
1482 pDLSEntry = DlsEntryTableLookup(pAd, pAd->StaCfg.DLSEntry[i].MacAddr, TRUE);
1483 pDLSEntry->PairwiseKey.CipherAlg=PairwiseKey.CipherAlg;
1484 RTUSBEnqueueInternalCmd(pAd, RT_CMD_SET_RX_WCID_TABLE, pDLSEntry, sizeof(MAC_TABLE_ENTRY));
1485 }
1486//Benson modified for USB interface, avoid in interrupt when write key, 20080724 <--
1487#endif // RT2870 //
1488 NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
1489 DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Initiator STA MAC Address STAKey)\n"));
1490
1491 // If support WPA or WPA2, start STAKey hand shake,
1492 // If failed hand shake, just tear down peer DLS
1493 if (RTMPSendSTAKeyHandShake(pAd, pAddr) != NDIS_STATUS_SUCCESS)
1494 {
1495 MLME_DLS_REQ_STRUCT MlmeDlsReq;
1496 USHORT reason = REASON_QOS_CIPHER_NOT_SUPPORT;
1497
1498 pAd->StaCfg.DLSEntry[i].Valid = FALSE;
1499 pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
1500 DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
1501 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
1502 }
1503 else
1504 {
1505 DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Peer side)\n"));
1506 }
1507 }
1508 else
1509 {
1510 // Data frame, update timeout value
1511 if (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
1512 {
1513 pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
1514 }
1515 }
1516
1517 bFindEntry = TRUE;
1518 }
1519 }
1520
1521
1522 return bSTAKeyFrame;
1523}
1524
1525/*
1526 ========================================================================
1527
1528 Routine Description:
1529 Check if the frame can be sent through DLS direct link interface
1530
1531 Arguments:
1532 pAd Pointer to adapter
1533
1534 Return Value:
1535 DLS entry index
1536
1537 Note:
1538
1539 ========================================================================
1540*/
1541INT RTMPCheckDLSFrame(
1542 IN PRTMP_ADAPTER pAd,
1543 IN PUCHAR pDA)
1544{
1545 INT rval = -1;
1546 INT i;
1547
1548 if (!pAd->CommonCfg.bDLSCapable)
1549 return rval;
1550
1551 if (!INFRA_ON(pAd))
1552 return rval;
1553
1554 do{
1555 // check local dls table entry
1556 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
1557 {
1558 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
1559 MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
1560 {
1561 rval = i;
1562 break;
1563 }
1564 }
1565
1566 // check peer dls table entry
1567 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
1568 {
1569 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
1570 MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
1571 {
1572 rval = i;
1573 break;
1574 }
1575 }
1576 } while (FALSE);
1577
1578 return rval;
1579}
1580
1581/*
1582 ==========================================================================
1583 Description:
1584
1585 IRQL = DISPATCH_LEVEL
1586
1587 ==========================================================================
1588 */
1589VOID RTMPSendDLSTearDownFrame(
1590 IN PRTMP_ADAPTER pAd,
1591 IN PUCHAR pDA)
1592{
1593 PUCHAR pOutBuffer = NULL;
1594 NDIS_STATUS NStatus;
1595 HEADER_802_11 DlsTearDownHdr;
1596 ULONG FrameLen = 0;
1597 USHORT Reason = REASON_QOS_QSTA_LEAVING_QBSS;
1598 UCHAR Category = CATEGORY_DLS;
1599 UCHAR Action = ACTION_DLS_TEARDOWN;
1600 UCHAR i = 0;
1601
1602 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
1603 RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
1604 return;
1605
1606 DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame \n"));
1607
1608 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
1609 if (NStatus != NDIS_STATUS_SUCCESS)
1610 {
1611 DBGPRINT(RT_DEBUG_ERROR,("ASSOC - RTMPSendDLSTearDownFrame() allocate memory failed \n"));
1612 return;
1613 }
1614
1615 ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
1616 MakeOutgoingFrame(pOutBuffer, &FrameLen,
1617 sizeof(HEADER_802_11), &DlsTearDownHdr,
1618 1, &Category,
1619 1, &Action,
1620 6, pDA,
1621 6, pAd->CurrentAddress,
1622 2, &Reason,
1623 END_OF_ARGS);
1624
1625 MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
1626 MlmeFreeMemory(pAd, pOutBuffer);
1627
1628 // Remove key in local dls table entry
1629 for (i = 0; i < MAX_NUM_OF_INIT_DLS_ENTRY; i++)
1630 {
1631 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
1632 && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
1633 {
1634 MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
1635 }
1636 }
1637
1638 // Remove key in peer dls table entry
1639 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
1640 {
1641 if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH)
1642 && MAC_ADDR_EQUAL(pDA, pAd->StaCfg.DLSEntry[i].MacAddr))
1643 {
1644 MacTableDeleteDlsEntry(pAd, pAd->StaCfg.DLSEntry[i].MacTabMatchWCID, pAd->StaCfg.DLSEntry[i].MacAddr);
1645 }
1646 }
1647
1648 DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame and remove key in (i=%d) \n", i));
1649}
1650
1651/*
1652 ==========================================================================
1653 Description:
1654
1655 IRQL = DISPATCH_LEVEL
1656
1657 ==========================================================================
1658 */
1659NDIS_STATUS RTMPSendSTAKeyRequest(
1660 IN PRTMP_ADAPTER pAd,
1661 IN PUCHAR pDA)
1662{
1663 UCHAR Header802_3[14];
1664 NDIS_STATUS NStatus;
1665 ULONG FrameLen = 0;
1666 EAPOL_PACKET Packet;
1667 UCHAR Mic[16];
1668 UCHAR digest[80];
1669 PUCHAR pOutBuffer = NULL;
1670 PNDIS_PACKET pNdisPacket;
1671 UCHAR temp[64];
1672 UCHAR DlsPTK[80];
1673
1674 DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyRequest() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
1675
1676 pAd->Sequence ++;
1677 MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
1678
1679 // Zero message body
1680 NdisZeroMemory(&Packet, sizeof(Packet));
1681 Packet.ProVer = EAPOL_VER;
1682 Packet.ProType = EAPOLKey;
1683 Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE andPeer MAC address
1684
1685 // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
1686 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
1687 {
1688 Packet.KeyDesc.Type = WPA1_KEY_DESC;
1689 }
1690 else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1691 {
1692 Packet.KeyDesc.Type = WPA2_KEY_DESC;
1693 }
1694
1695 // Key descriptor version
1696 Packet.KeyDesc.KeyInfo.KeyDescVer =
1697 (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
1698
1699 Packet.KeyDesc.KeyInfo.KeyMic = 1;
1700 Packet.KeyDesc.KeyInfo.Secure = 1;
1701 Packet.KeyDesc.KeyInfo.Request = 1;
1702
1703 Packet.KeyDesc.KeyDataLen[1] = 12;
1704
1705 // use our own OUI to distinguish proprietary with standard.
1706 Packet.KeyDesc.KeyData[0] = 0xDD;
1707 Packet.KeyDesc.KeyData[1] = 0x0A;
1708 Packet.KeyDesc.KeyData[2] = 0x00;
1709 Packet.KeyDesc.KeyData[3] = 0x0C;
1710 Packet.KeyDesc.KeyData[4] = 0x43;
1711 Packet.KeyDesc.KeyData[5] = 0x03;
1712 NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
1713
1714 NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
1715
1716 // Allocate buffer for transmitting message
1717 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
1718 if (NStatus != NDIS_STATUS_SUCCESS)
1719 return NStatus;
1720
1721 // Prepare EAPOL frame for MIC calculation
1722 // Be careful, only EAPOL frame is counted for MIC calculation
1723 MakeOutgoingFrame(pOutBuffer, &FrameLen,
1724 Packet.Body_Len[1] + 4, &Packet,
1725 END_OF_ARGS);
1726
1727 // use proprietary PTK
1728 NdisZeroMemory(temp, 64);
1729 NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
1730 WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
1731
1732 // calculate MIC
1733 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
1734 {
1735 // AES
1736 NdisZeroMemory(digest, sizeof(digest));
1737 HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
1738 NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
1739 }
1740 else
1741 {
1742 NdisZeroMemory(Mic, sizeof(Mic));
1743 hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
1744 NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
1745 }
1746
1747 MakeOutgoingFrame(pOutBuffer, &FrameLen,
1748 sizeof(Header802_3), Header802_3,
1749 Packet.Body_Len[1] + 4, &Packet,
1750 END_OF_ARGS);
1751
1752 NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
1753 if (NStatus == NDIS_STATUS_SUCCESS)
1754 {
1755 RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
1756 STASendPacket(pAd, pNdisPacket);
1757 RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
1758 }
1759
1760 MlmeFreeMemory(pAd, pOutBuffer);
1761
1762 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyRequest- Send STAKey request (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
1763
1764 return NStatus;
1765}
1766
1767/*
1768 ==========================================================================
1769 Description:
1770
1771 IRQL = DISPATCH_LEVEL
1772
1773 ==========================================================================
1774 */
1775NDIS_STATUS RTMPSendSTAKeyHandShake(
1776 IN PRTMP_ADAPTER pAd,
1777 IN PUCHAR pDA)
1778{
1779 UCHAR Header802_3[14];
1780 NDIS_STATUS NStatus;
1781 ULONG FrameLen = 0;
1782 EAPOL_PACKET Packet;
1783 UCHAR Mic[16];
1784 UCHAR digest[80];
1785 PUCHAR pOutBuffer = NULL;
1786 PNDIS_PACKET pNdisPacket;
1787 UCHAR temp[64];
1788 UCHAR DlsPTK[80]; // Due to dirver can not get PTK, use proprietary PTK
1789
1790 DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyHandShake() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
1791
1792 pAd->Sequence ++;
1793 MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
1794
1795 // Zero message body
1796 NdisZeroMemory(&Packet, sizeof(Packet));
1797 Packet.ProVer = EAPOL_VER;
1798 Packet.ProType = EAPOLKey;
1799 Packet.Body_Len[1] = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN; // data field contain KDE and Peer MAC address
1800
1801 // STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
1802 if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
1803 {
1804 Packet.KeyDesc.Type = WPA1_KEY_DESC;
1805 }
1806 else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
1807 {
1808 Packet.KeyDesc.Type = WPA2_KEY_DESC;
1809 }
1810
1811 // Key descriptor version
1812 Packet.KeyDesc.KeyInfo.KeyDescVer =
1813 (((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
1814
1815 Packet.KeyDesc.KeyInfo.KeyMic = 1;
1816 Packet.KeyDesc.KeyInfo.Secure = 1;
1817
1818 Packet.KeyDesc.KeyDataLen[1] = 12;
1819
1820 // use our own OUI to distinguish proprietary with standard.
1821 Packet.KeyDesc.KeyData[0] = 0xDD;
1822 Packet.KeyDesc.KeyData[1] = 0x0A;
1823 Packet.KeyDesc.KeyData[2] = 0x00;
1824 Packet.KeyDesc.KeyData[3] = 0x0C;
1825 Packet.KeyDesc.KeyData[4] = 0x43;
1826 Packet.KeyDesc.KeyData[5] = 0x03;
1827 NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
1828
1829 NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
1830
1831 // Allocate buffer for transmitting message
1832 NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
1833 if (NStatus != NDIS_STATUS_SUCCESS)
1834 return NStatus;
1835
1836 // Prepare EAPOL frame for MIC calculation
1837 // Be careful, only EAPOL frame is counted for MIC calculation
1838 MakeOutgoingFrame(pOutBuffer, &FrameLen,
1839 Packet.Body_Len[1] + 4, &Packet,
1840 END_OF_ARGS);
1841
1842 // use proprietary PTK
1843 NdisZeroMemory(temp, 64);
1844 NdisMoveMemory(temp, "IEEE802.11 WIRELESS ACCESS POINT", 32);
1845 WpaCountPTK(pAd, temp, temp, pAd->CommonCfg.Bssid, temp, pAd->CurrentAddress, DlsPTK, LEN_PTK);
1846
1847 // calculate MIC
1848 if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
1849 {
1850 // AES
1851 NdisZeroMemory(digest, sizeof(digest));
1852 HMAC_SHA1(pOutBuffer, FrameLen, DlsPTK, LEN_EAP_MICK, digest);
1853 NdisMoveMemory(Packet.KeyDesc.KeyMic, digest, LEN_KEY_DESC_MIC);
1854 }
1855 else
1856 {
1857 NdisZeroMemory(Mic, sizeof(Mic));
1858 hmac_md5(DlsPTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
1859 NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
1860 }
1861
1862 MakeOutgoingFrame(pOutBuffer, &FrameLen,
1863 sizeof(Header802_3), Header802_3,
1864 Packet.Body_Len[1] + 4, &Packet,
1865 END_OF_ARGS);
1866
1867 NStatus = RTMPAllocateNdisPacket(pAd, &pNdisPacket, NULL, 0, pOutBuffer, FrameLen);
1868 if (NStatus == NDIS_STATUS_SUCCESS)
1869 {
1870 RTMP_SET_PACKET_WCID(pNdisPacket, BSSID_WCID);
1871 STASendPacket(pAd, pNdisPacket);
1872 RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
1873 }
1874
1875 MlmeFreeMemory(pAd, pOutBuffer);
1876
1877 DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyHandShake- Send STAKey Message-2 (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
1878
1879 return NStatus;
1880}
1881
1882VOID DlsTimeoutAction(
1883 IN PVOID SystemSpecific1,
1884 IN PVOID FunctionContext,
1885 IN PVOID SystemSpecific2,
1886 IN PVOID SystemSpecific3)
1887{
1888 MLME_DLS_REQ_STRUCT MlmeDlsReq;
1889 USHORT reason;
1890 PRT_802_11_DLS pDLS = (PRT_802_11_DLS)FunctionContext;
1891 PRTMP_ADAPTER pAd = pDLS->pAd;
1892
1893 DBGPRINT(RT_DEBUG_TRACE, ("DlsTimeout - Tear down DLS links (%02x:%02x:%02x:%02x:%02x:%02x)\n",
1894 pDLS->MacAddr[0], pDLS->MacAddr[1], pDLS->MacAddr[2], pDLS->MacAddr[3], pDLS->MacAddr[4], pDLS->MacAddr[5]));
1895
1896 if ((pDLS) && (pDLS->Valid))
1897 {
1898 reason = REASON_QOS_REQUEST_TIMEOUT;
1899 pDLS->Valid = FALSE;
1900 pDLS->Status = DLS_NONE;
1901 DlsParmFill(pAd, &MlmeDlsReq, pDLS, reason);
1902 MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
1903 RT28XX_MLME_HANDLER(pAd);
1904 }
1905}
1906
1907/*
1908================================================================
1909Description : because DLS and CLI share the same WCID table in ASIC.
1910Mesh entry also insert to pAd->MacTab.content[]. Such is marked as ValidAsDls = TRUE.
1911Also fills the pairwise key.
1912Because front MAX_AID_BA entries have direct mapping to BAEntry, which is only used as CLI. So we insert Dls
1913from index MAX_AID_BA.
1914================================================================
1915*/
1916MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
1917 IN PRTMP_ADAPTER pAd,
1918 IN PUCHAR pAddr,
1919 IN UINT DlsEntryIdx)
1920{
1921 PMAC_TABLE_ENTRY pEntry = NULL;
1922
1923 DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableInsertDlsEntry\n"));
1924 // if FULL, return
1925 if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
1926 return NULL;
1927
1928 do
1929 {
1930 if((pEntry = DlsEntryTableLookup(pAd, pAddr, TRUE)) != NULL)
1931 break;
1932
1933 // allocate one MAC entry
1934 pEntry = MacTableInsertEntry(pAd, pAddr, DlsEntryIdx + MIN_NET_DEVICE_FOR_DLS, TRUE);
1935 if (pEntry)
1936 {
1937 pAd->StaCfg.DLSEntry[DlsEntryIdx].MacTabMatchWCID = pEntry->Aid;
1938 pEntry->MatchDlsEntryIdx = DlsEntryIdx;
1939 pEntry->AuthMode = pAd->StaCfg.AuthMode;
1940 pEntry->WepStatus = pAd->StaCfg.WepStatus;
1941
1942 DBGPRINT(RT_DEBUG_TRACE, ("MacTableInsertDlsEntry - allocate entry #%d, Total= %d\n",pEntry->Aid, pAd->MacTab.Size));
1943
1944 // If legacy WEP is used, set pair-wise cipherAlg into WCID attribute table for this entry
1945 if ((pEntry->ValidAsDls) && (pEntry->WepStatus == Ndis802_11WEPEnabled))
1946 {
1947 UCHAR KeyIdx = 0;
1948 UCHAR CipherAlg = 0;
1949
1950 KeyIdx = pAd->StaCfg.DefaultKeyId;
1951
1952 CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
1953
1954 RTMPAddWcidAttributeEntry(pAd,
1955 BSS0,
1956 pAd->StaCfg.DefaultKeyId,
1957 pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
1958 pEntry);
1959 }
1960
1961 break;
1962 }
1963 } while(FALSE);
1964
1965 DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableInsertDlsEntry\n"));
1966
1967 return pEntry;
1968}
1969
1970
1971/*
1972 ==========================================================================
1973 Description:
1974 Delete all Mesh Entry in pAd->MacTab
1975 ==========================================================================
1976 */
1977BOOLEAN MacTableDeleteDlsEntry(
1978 IN PRTMP_ADAPTER pAd,
1979 IN USHORT wcid,
1980 IN PUCHAR pAddr)
1981{
1982 DBGPRINT(RT_DEBUG_TRACE, ("====> MacTableDeleteDlsEntry\n"));
1983
1984 if (!VALID_WCID(wcid))
1985 return FALSE;
1986
1987 MacTableDeleteEntry(pAd, wcid, pAddr);
1988
1989 DBGPRINT(RT_DEBUG_TRACE, ("<==== MacTableDeleteDlsEntry\n"));
1990
1991 return TRUE;
1992}
1993
1994MAC_TABLE_ENTRY *DlsEntryTableLookup(
1995 IN PRTMP_ADAPTER pAd,
1996 IN PUCHAR pAddr,
1997 IN BOOLEAN bResetIdelCount)
1998{
1999 ULONG HashIdx;
2000 MAC_TABLE_ENTRY *pEntry = NULL;
2001
2002 RTMP_SEM_LOCK(&pAd->MacTabLock);
2003 HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
2004 pEntry = pAd->MacTab.Hash[HashIdx];
2005
2006 while (pEntry)
2007 {
2008 if ((pEntry->ValidAsDls == TRUE)
2009 && MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
2010 {
2011 if(bResetIdelCount)
2012 pEntry->NoDataIdleCount = 0;
2013 break;
2014 }
2015 else
2016 pEntry = pEntry->pNext;
2017 }
2018
2019 RTMP_SEM_UNLOCK(&pAd->MacTabLock);
2020 return pEntry;
2021}
2022
2023MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
2024 IN PRTMP_ADAPTER pAd,
2025 IN UCHAR wcid,
2026 IN PUCHAR pAddr,
2027 IN BOOLEAN bResetIdelCount)
2028{
2029 ULONG DLsIndex;
2030 PMAC_TABLE_ENTRY pCurEntry = NULL;
2031 PMAC_TABLE_ENTRY pEntry = NULL;
2032
2033 if (!VALID_WCID(wcid))
2034 return NULL;
2035
2036 RTMP_SEM_LOCK(&pAd->MacTabLock);
2037
2038 do
2039 {
2040 pCurEntry = &pAd->MacTab.Content[wcid];
2041
2042 DLsIndex = 0xff;
2043 if ((pCurEntry) && (pCurEntry->ValidAsDls== TRUE))
2044 {
2045 DLsIndex = pCurEntry->MatchDlsEntryIdx;
2046 }
2047
2048 if (DLsIndex == 0xff)
2049 break;
2050
2051 if (MAC_ADDR_EQUAL(pCurEntry->Addr, pAddr))
2052 {
2053 if(bResetIdelCount)
2054 pCurEntry->NoDataIdleCount = 0;
2055 pEntry = pCurEntry;
2056 break;
2057 }
2058 } while(FALSE);
2059
2060 RTMP_SEM_UNLOCK(&pAd->MacTabLock);
2061
2062 return pEntry;
2063}
2064
2065INT Set_DlsEntryInfo_Display_Proc(
2066 IN PRTMP_ADAPTER pAd,
2067 IN PUCHAR arg)
2068{
2069 INT i;
2070
2071 printk("\n%-19s%-8s\n", "MAC", "TIMEOUT\n");
2072 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
2073 {
2074 if ((pAd->StaCfg.DLSEntry[i].Valid) && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))
2075 {
2076 printk("%02x:%02x:%02x:%02x:%02x:%02x ",
2077 pAd->StaCfg.DLSEntry[i].MacAddr[0], pAd->StaCfg.DLSEntry[i].MacAddr[1], pAd->StaCfg.DLSEntry[i].MacAddr[2],
2078 pAd->StaCfg.DLSEntry[i].MacAddr[3], pAd->StaCfg.DLSEntry[i].MacAddr[4], pAd->StaCfg.DLSEntry[i].MacAddr[5]);
2079 printk("%-8d\n", pAd->StaCfg.DLSEntry[i].TimeOut);
2080 }
2081 }
2082
2083 return TRUE;
2084}
2085
2086INT Set_DlsAddEntry_Proc(
2087 IN PRTMP_ADAPTER pAd,
2088 IN PUCHAR arg)
2089{
2090 UCHAR mac[MAC_ADDR_LEN];
2091 USHORT Timeout;
2092 char *token, sepValue[] = ":", DASH = '-';
2093 INT i;
2094 RT_802_11_DLS Dls;
2095
2096 if(strlen(arg) < 19) //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and timeout value in decimal format.
2097 return FALSE;
2098
2099 token = strchr(arg, DASH);
2100 if ((token != NULL) && (strlen(token)>1))
2101 {
2102 Timeout = simple_strtol((token+1), 0, 10);
2103
2104 *token = '\0';
2105 for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
2106 {
2107 if((strlen(token) != 2) || (!isxdigit(*token)) || (!isxdigit(*(token+1))))
2108 return FALSE;
2109 AtoH(token, (PUCHAR)(&mac[i]), 1);
2110 }
2111 if(i != 6)
2112 return FALSE;
2113
2114 printk("\n%02x:%02x:%02x:%02x:%02x:%02x-%d", mac[0], mac[1],
2115 mac[2], mac[3], mac[4], mac[5], (int)Timeout);
2116
2117 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
2118 Dls.TimeOut = Timeout;
2119 COPY_MAC_ADDR(Dls.MacAddr, mac);
2120 Dls.Valid = 1;
2121
2122 MlmeEnqueue(pAd,
2123 MLME_CNTL_STATE_MACHINE,
2124 RT_OID_802_11_SET_DLS_PARAM,
2125 sizeof(RT_802_11_DLS),
2126 &Dls);
2127
2128 return TRUE;
2129 }
2130
2131 return FALSE;
2132
2133}
2134
2135INT Set_DlsTearDownEntry_Proc(
2136 IN PRTMP_ADAPTER pAd,
2137 IN PUCHAR arg)
2138{
2139 UCHAR macAddr[MAC_ADDR_LEN];
2140 CHAR *value;
2141 INT i;
2142 RT_802_11_DLS Dls;
2143
2144 if(strlen(arg) != 17) //Mac address acceptable format 01:02:03:04:05:06 length 17
2145 return FALSE;
2146
2147 for (i=0, value = rstrtok(arg,":"); value; value = rstrtok(NULL,":"))
2148 {
2149 if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
2150 return FALSE; //Invalid
2151
2152 AtoH(value, &macAddr[i++], 2);
2153 }
2154
2155 printk("\n%02x:%02x:%02x:%02x:%02x:%02x", macAddr[0], macAddr[1],
2156 macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
2157
2158 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
2159 COPY_MAC_ADDR(Dls.MacAddr, macAddr);
2160 Dls.Valid = 0;
2161
2162 MlmeEnqueue(pAd,
2163 MLME_CNTL_STATE_MACHINE,
2164 RT_OID_802_11_SET_DLS_PARAM,
2165 sizeof(RT_802_11_DLS),
2166 &Dls);
2167
2168 return TRUE;
2169}
2170
diff --git a/drivers/staging/rt3070/sta/rtmp_data.c b/drivers/staging/rt3070/sta/rtmp_data.c
index 8112c20e7fa..68add1f88bb 100644
--- a/drivers/staging/rt3070/sta/rtmp_data.c
+++ b/drivers/staging/rt3070/sta/rtmp_data.c
@@ -183,9 +183,6 @@ VOID STARxDataFrameAnnounce(
183 // ARALINK 183 // ARALINK
184 CmmRxRalinkFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID); 184 CmmRxRalinkFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
185 } 185 }
186#ifdef QOS_DLS_SUPPORT
187 RX_BLK_CLEAR_FLAG(pRxBlk, fRX_DLS);
188#endif // QOS_DLS_SUPPORT //
189 } 186 }
190 else 187 else
191 { 188 {
@@ -291,14 +288,6 @@ VOID STAHandleRxDataFrame(
291 return; 288 return;
292 } 289 }
293 290
294#ifdef QOS_DLS_SUPPORT
295 //if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
296 if (RTMPRcvFrameDLSCheck(pAd, pHeader, pRxWI->MPDUtotalByteCount, pRxD))
297 {
298 return;
299 }
300#endif // QOS_DLS_SUPPORT //
301
302 // Drop not my BSS frames 291 // Drop not my BSS frames
303 if (pRxD->MyBss == 0) 292 if (pRxD->MyBss == 0)
304 { 293 {
@@ -357,10 +346,7 @@ VOID STAHandleRxDataFrame(
357 } 346 }
358 347
359 // Drop not my BSS frame (we can not only check the MyBss bit in RxD) 348 // Drop not my BSS frame (we can not only check the MyBss bit in RxD)
360#ifdef QOS_DLS_SUPPORT 349
361 if (!pAd->CommonCfg.bDLSCapable)
362 {
363#endif // QOS_DLS_SUPPORT //
364 if (INFRA_ON(pAd)) 350 if (INFRA_ON(pAd))
365 { 351 {
366 // Infrastructure mode, check address 2 for BSSID 352 // Infrastructure mode, check address 2 for BSSID
@@ -383,9 +369,6 @@ VOID STAHandleRxDataFrame(
383 return; 369 return;
384 } 370 }
385 } 371 }
386#ifdef QOS_DLS_SUPPORT
387 }
388#endif // QOS_DLS_SUPPORT //
389 372
390 // 373 //
391 // find pEntry 374 // find pEntry
@@ -406,11 +389,6 @@ VOID STAHandleRxDataFrame(
406 if (INFRA_ON(pAd)) 389 if (INFRA_ON(pAd))
407 { 390 {
408 RX_BLK_SET_FLAG(pRxBlk, fRX_INFRA); 391 RX_BLK_SET_FLAG(pRxBlk, fRX_INFRA);
409#ifdef QOS_DLS_SUPPORT
410 if ((pHeader->FC.FrDs == 0) && (pHeader->FC.ToDs == 0))
411 RX_BLK_SET_FLAG(pRxBlk, fRX_DLS);
412 else
413#endif // QOS_DLS_SUPPORT //
414 ASSERT(pRxWI->WirelessCliID == BSSID_WCID); 392 ASSERT(pRxWI->WirelessCliID == BSSID_WCID);
415 } 393 }
416 394
@@ -524,18 +502,6 @@ VOID STAHandleRxDataFrame(
524 { 502 {
525 pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ; 503 pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
526 504
527
528#ifdef QOS_DLS_SUPPORT
529 if (RX_BLK_TEST_FLAG(pRxBlk, fRX_DLS))
530 {
531 MAC_TABLE_ENTRY *pDlsEntry = NULL;
532
533 pDlsEntry = DlsEntryTableLookupByWcid(pAd, pRxWI->WirelessCliID, pHeader->Addr2, TRUE);
534 if(pDlsEntry)
535 Update_Rssi_Sample(pAd, &pDlsEntry->RssiSample, pRxWI);
536 }
537 else
538#endif // QOS_DLS_SUPPORT //
539 if (ADHOC_ON(pAd)) 505 if (ADHOC_ON(pAd))
540 { 506 {
541 pEntry = MacTableLookup(pAd, pHeader->Addr2); 507 pEntry = MacTableLookup(pAd, pHeader->Addr2);
@@ -885,17 +851,6 @@ VOID STASendPackets(
885 { 851 {
886 // Record that orignal packet source is from NDIS layer,so that 852 // Record that orignal packet source is from NDIS layer,so that
887 // later on driver knows how to release this NDIS PACKET 853 // later on driver knows how to release this NDIS PACKET
888#ifdef QOS_DLS_SUPPORT
889 MAC_TABLE_ENTRY *pEntry;
890 PUCHAR pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
891
892 pEntry = MacTableLookup(pAd, pSrcBufVA);
893 if (pEntry && (pEntry->ValidAsDls == TRUE))
894 {
895 RTMP_SET_PACKET_WCID(pPacket, pEntry->Aid);
896 }
897 else
898#endif // QOS_DLS_SUPPORT //
899 RTMP_SET_PACKET_WCID(pPacket, 0); // this field is useless when in STA mode 854 RTMP_SET_PACKET_WCID(pPacket, 0); // this field is useless when in STA mode
900 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS); 855 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
901 NDIS_SET_PACKET_STATUS(pPacket, NDIS_STATUS_PENDING); 856 NDIS_SET_PACKET_STATUS(pPacket, NDIS_STATUS_PENDING);
@@ -978,18 +933,6 @@ NDIS_STATUS STASendPacket(
978 { 933 {
979 if(INFRA_ON(pAd)) 934 if(INFRA_ON(pAd))
980 { 935 {
981#ifdef QOS_DLS_SUPPORT
982 USHORT tmpWcid;
983
984 tmpWcid = RTMP_GET_PACKET_WCID(pPacket);
985 if (VALID_WCID(tmpWcid) &&
986 (pAd->MacTab.Content[tmpWcid].ValidAsDls== TRUE))
987 {
988 pEntry = &pAd->MacTab.Content[tmpWcid];
989 Rate = pAd->MacTab.Content[tmpWcid].CurrTxRate;
990 }
991 else
992#endif // QOS_DLS_SUPPORT //
993 { 936 {
994 pEntry = &pAd->MacTab.Content[BSSID_WCID]; 937 pEntry = &pAd->MacTab.Content[BSSID_WCID];
995 RTMP_SET_PACKET_WCID(pPacket, BSSID_WCID); 938 RTMP_SET_PACKET_WCID(pPacket, BSSID_WCID);
@@ -1471,12 +1414,7 @@ VOID STABuildCommon802_11Header(
1471 IN PRTMP_ADAPTER pAd, 1414 IN PRTMP_ADAPTER pAd,
1472 IN TX_BLK *pTxBlk) 1415 IN TX_BLK *pTxBlk)
1473{ 1416{
1474
1475 HEADER_802_11 *pHeader_802_11; 1417 HEADER_802_11 *pHeader_802_11;
1476#ifdef QOS_DLS_SUPPORT
1477 BOOLEAN bDLSFrame = FALSE;
1478 INT DlsEntryIndex = 0;
1479#endif // QOS_DLS_SUPPORT //
1480 1418
1481 // 1419 //
1482 // MAKE A COMMON 802.11 HEADER 1420 // MAKE A COMMON 802.11 HEADER
@@ -1493,19 +1431,6 @@ VOID STABuildCommon802_11Header(
1493 pHeader_802_11->FC.Type = BTYPE_DATA; 1431 pHeader_802_11->FC.Type = BTYPE_DATA;
1494 pHeader_802_11->FC.SubType = ((TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) ? SUBTYPE_QDATA : SUBTYPE_DATA); 1432 pHeader_802_11->FC.SubType = ((TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) ? SUBTYPE_QDATA : SUBTYPE_DATA);
1495 1433
1496#ifdef QOS_DLS_SUPPORT
1497 if (INFRA_ON(pAd))
1498 {
1499 // Check if the frame can be sent through DLS direct link interface
1500 // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
1501 DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
1502 if (DlsEntryIndex >= 0)
1503 bDLSFrame = TRUE;
1504 else
1505 bDLSFrame = FALSE;
1506 }
1507#endif // QOS_DLS_SUPPORT //
1508
1509 if (pTxBlk->pMacEntry) 1434 if (pTxBlk->pMacEntry)
1510 { 1435 {
1511 if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS)) 1436 if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS))
@@ -1515,14 +1440,6 @@ VOID STABuildCommon802_11Header(
1515 } 1440 }
1516 else 1441 else
1517 { 1442 {
1518#ifdef QOS_DLS_SUPPORT
1519 if (bDLSFrame)
1520 {
1521 pHeader_802_11->Sequence = pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence;
1522 pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence = (pAd->StaCfg.DLSEntry[DlsEntryIndex].Sequence+1) & MAXSEQ;
1523 }
1524 else
1525#endif // QOS_DLS_SUPPORT //
1526 { 1443 {
1527 pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]; 1444 pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority];
1528 pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ; 1445 pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
@@ -1542,16 +1459,6 @@ VOID STABuildCommon802_11Header(
1542 { 1459 {
1543 if (INFRA_ON(pAd)) 1460 if (INFRA_ON(pAd))
1544 { 1461 {
1545#ifdef QOS_DLS_SUPPORT
1546 if (bDLSFrame)
1547 {
1548 COPY_MAC_ADDR(pHeader_802_11->Addr1, pTxBlk->pSrcBufHeader);
1549 COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
1550 COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
1551 pHeader_802_11->FC.ToDs = 0;
1552 }
1553 else
1554#endif // QOS_DLS_SUPPORT //
1555 { 1462 {
1556 COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid); 1463 COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
1557 COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress); 1464 COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
@@ -1607,29 +1514,7 @@ VOID STABuildCache802_11Header(
1607 pMacEntry->TxSeq[pTxBlk->UserPriority] = (pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ; 1514 pMacEntry->TxSeq[pTxBlk->UserPriority] = (pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
1608 1515
1609 { 1516 {
1610 // Check if the frame can be sent through DLS direct link interface
1611 // If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
1612#ifdef QOS_DLS_SUPPORT
1613 BOOLEAN bDLSFrame = FALSE;
1614 INT DlsEntryIndex = 0;
1615
1616 DlsEntryIndex = RTMPCheckDLSFrame(pAd, pTxBlk->pSrcBufHeader);
1617 if (DlsEntryIndex >= 0)
1618 bDLSFrame = TRUE;
1619 else
1620 bDLSFrame = FALSE;
1621#endif // QOS_DLS_SUPPORT //
1622
1623 // The addr3 of normal packet send from DS is Dest Mac address. 1517 // The addr3 of normal packet send from DS is Dest Mac address.
1624#ifdef QOS_DLS_SUPPORT
1625 if (bDLSFrame)
1626 {
1627 COPY_MAC_ADDR(pHeader80211->Addr1, pTxBlk->pSrcBufHeader);
1628 COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
1629 pHeader80211->FC.ToDs = 0;
1630 }
1631 else
1632#endif // QOS_DLS_SUPPORT //
1633 if (ADHOC_ON(pAd)) 1518 if (ADHOC_ON(pAd))
1634 COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid); 1519 COPY_MAC_ADDR(pHeader80211->Addr3, pAd->CommonCfg.Bssid);
1635 else 1520 else
diff --git a/drivers/staging/rt3070/sta_ioctl.c b/drivers/staging/rt3070/sta_ioctl.c
index 1495ff386e5..c7b20709753 100644
--- a/drivers/staging/rt3070/sta_ioctl.c
+++ b/drivers/staging/rt3070/sta_ioctl.c
@@ -85,10 +85,6 @@ struct iw_priv_args privtab[] = {
85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" }, 85 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_off" },
86 { RAIO_ON, 86 { RAIO_ON,
87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" }, 87 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "radio_on" },
88#ifdef QOS_DLS_SUPPORT
89 { SHOW_DLS_ENTRY_INFO,
90 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "dlsentryinfo" },
91#endif // QOS_DLS_SUPPORT //
92 { SHOW_CFG_VALUE, 88 { SHOW_CFG_VALUE,
93 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" }, 89 IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "show" },
94/* --- sub-ioctls relations --- */ 90/* --- sub-ioctls relations --- */
@@ -289,10 +285,6 @@ static struct {
289 {"TGnWifiTest", Set_TGnWifiTest_Proc}, 285 {"TGnWifiTest", Set_TGnWifiTest_Proc},
290 {"ForceGF", Set_ForceGF_Proc}, 286 {"ForceGF", Set_ForceGF_Proc},
291#endif // DOT11_N_SUPPORT // 287#endif // DOT11_N_SUPPORT //
292#ifdef QOS_DLS_SUPPORT
293 {"DlsAddEntry", Set_DlsAddEntry_Proc},
294 {"DlsTearDownEntry", Set_DlsTearDownEntry_Proc},
295#endif // QOS_DLS_SUPPORT //
296 {"LongRetry", Set_LongRetryLimit_Proc}, 288 {"LongRetry", Set_LongRetryLimit_Proc},
297 {"ShortRetry", Set_ShortRetryLimit_Proc}, 289 {"ShortRetry", Set_ShortRetryLimit_Proc},
298#ifdef EXT_BUILD_CHANNEL_LIST 290#ifdef EXT_BUILD_CHANNEL_LIST
@@ -2057,16 +2049,6 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
2057 wrq->length = strlen(extra) + 1; // 1: size of '\0' 2049 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2058 break; 2050 break;
2059 2051
2060
2061#ifdef QOS_DLS_SUPPORT
2062 case SHOW_DLS_ENTRY_INFO:
2063 {
2064 Set_DlsEntryInfo_Display_Proc(pAd, NULL);
2065 wrq->length = 0; // 1: size of '\0'
2066 }
2067 break;
2068#endif // QOS_DLS_SUPPORT //
2069
2070 case SHOW_CFG_VALUE: 2052 case SHOW_CFG_VALUE:
2071 { 2053 {
2072 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra); 2054 Status = RTMPShowCfgValue(pAd, wrq->pointer, extra);
@@ -3813,62 +3795,7 @@ INT RTMPSetInformation(
3813 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave)); 3795 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_APSD_PSM (bAPSDForcePowerSave:%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
3814 } 3796 }
3815 break; 3797 break;
3816#ifdef QOS_DLS_SUPPORT
3817 case RT_OID_802_11_SET_DLS:
3818 if (wrq->u.data.length != sizeof(ULONG))
3819 Status = -EINVAL;
3820 else
3821 {
3822 BOOLEAN oldvalue = pAdapter->CommonCfg.bDLSCapable;
3823 Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
3824 if (oldvalue && !pAdapter->CommonCfg.bDLSCapable)
3825 {
3826 int i;
3827 // tear down local dls table entry
3828 for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)
3829 {
3830 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3831 {
3832 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3833 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3834 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3835 }
3836 }
3837
3838 // tear down peer dls table entry
3839 for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)
3840 {
3841 if (pAdapter->StaCfg.DLSEntry[i].Valid && (pAdapter->StaCfg.DLSEntry[i].Status == DLS_FINISH))
3842 {
3843 pAdapter->StaCfg.DLSEntry[i].Status = DLS_NONE;
3844 pAdapter->StaCfg.DLSEntry[i].Valid = FALSE;
3845 RTMPSendDLSTearDownFrame(pAdapter, pAdapter->StaCfg.DLSEntry[i].MacAddr);
3846 }
3847 }
3848 }
3849
3850 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS (=%d)\n", pAdapter->CommonCfg.bDLSCapable));
3851 }
3852 break;
3853
3854 case RT_OID_802_11_SET_DLS_PARAM:
3855 if (wrq->u.data.length != sizeof(RT_802_11_DLS_UI))
3856 Status = -EINVAL;
3857 else
3858 {
3859 RT_802_11_DLS Dls;
3860 3798
3861 NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
3862 RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
3863 MlmeEnqueue(pAdapter,
3864 MLME_CNTL_STATE_MACHINE,
3865 RT_OID_802_11_SET_DLS_PARAM,
3866 sizeof(RT_802_11_DLS),
3867 &Dls);
3868 DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
3869 }
3870 break;
3871#endif // QOS_DLS_SUPPORT //
3872 case RT_OID_802_11_SET_WMM: 3799 case RT_OID_802_11_SET_WMM:
3873 if (wrq->u.data.length != sizeof(BOOLEAN)) 3800 if (wrq->u.data.length != sizeof(BOOLEAN))
3874 Status = -EINVAL; 3801 Status = -EINVAL;
@@ -5203,35 +5130,6 @@ INT RTMPQueryInformation(
5203 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status)); 5130 DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
5204 break; 5131 break;
5205 5132
5206
5207#ifdef QOS_DLS_SUPPORT
5208 case RT_OID_802_11_QUERY_DLS:
5209 wrq->u.data.length = sizeof(BOOLEAN);
5210 Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bDLSCapable, wrq->u.data.length);
5211 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS(=%d)\n", pAdapter->CommonCfg.bDLSCapable));
5212 break;
5213
5214 case RT_OID_802_11_QUERY_DLS_PARAM:
5215 {
5216 PRT_802_11_DLS_INFO pDlsInfo = kmalloc(sizeof(RT_802_11_DLS_INFO), GFP_ATOMIC);
5217 if (pDlsInfo == NULL)
5218 break;
5219
5220 for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)
5221 {
5222 RTMPMoveMemory(&pDlsInfo->Entry[i], &pAdapter->StaCfg.DLSEntry[i], sizeof(RT_802_11_DLS_UI));
5223 }
5224
5225 pDlsInfo->num = MAX_NUM_OF_DLS_ENTRY;
5226 wrq->u.data.length = sizeof(RT_802_11_DLS_INFO);
5227 Status = copy_to_user(wrq->u.data.pointer, pDlsInfo, wrq->u.data.length);
5228 DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_DLS_PARAM\n"));
5229
5230 if (pDlsInfo)
5231 kfree(pDlsInfo);
5232 }
5233 break;
5234#endif // QOS_DLS_SUPPORT //
5235 default: 5133 default:
5236 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd)); 5134 DBGPRINT(RT_DEBUG_TRACE, ("Query::unknown IOCTL's subcmd = 0x%08x\n", cmd));
5237 Status = -EOPNOTSUPP; 5135 Status = -EOPNOTSUPP;