aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2006-11-21 19:06:38 -0500
committerJeff Garzik <jeff@garzik.org>2006-12-02 00:12:05 -0500
commitb1cd84167b92de0f9fc7aad9cf272261496f4d0b (patch)
treee3555266489e8c0ce384c86b1bcd1833fcfdcff4
parent35f2c7c0ce8eb09d19fb50ed2cd29b6dbea9cd86 (diff)
[PATCH] zd1211rw: Rename cs_rate to zd_rate
These controlset rate constants are also applicable in places outside the controlset, such as in the RTS/CTS control register. Signed-off-by: Daniel Drake <dsd@gentoo.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.h1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c56
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h9
3 files changed, 34 insertions, 32 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
index 36329890dfec..26b8298dff8c 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.h
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
@@ -50,6 +50,7 @@ static inline u8 zd_ofdm_plcp_header_rate(
50 return header->prefix[0] & 0xf; 50 return header->prefix[0] & 0xf;
51} 51}
52 52
53/* These are referred to as zd_rates */
53#define ZD_OFDM_RATE_6M 0xb 54#define ZD_OFDM_RATE_6M 0xb
54#define ZD_OFDM_RATE_9M 0xf 55#define ZD_OFDM_RATE_9M 0xf
55#define ZD_OFDM_RATE_12M 0xa 56#define ZD_OFDM_RATE_12M 0xa
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 0bb53f0b8bdd..e6af18304bac 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -325,13 +325,13 @@ u8 zd_mac_get_channel(struct zd_mac *mac)
325} 325}
326 326
327/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */ 327/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */
328static u8 cs_typed_rate(u8 cs_rate) 328static u8 zd_rate_typed(u8 zd_rate)
329{ 329{
330 static const u8 typed_rates[16] = { 330 static const u8 typed_rates[16] = {
331 [ZD_CS_CCK_RATE_1M] = ZD_CS_CCK|ZD_CS_CCK_RATE_1M, 331 [ZD_CCK_RATE_1M] = ZD_CS_CCK|ZD_CCK_RATE_1M,
332 [ZD_CS_CCK_RATE_2M] = ZD_CS_CCK|ZD_CS_CCK_RATE_2M, 332 [ZD_CCK_RATE_2M] = ZD_CS_CCK|ZD_CCK_RATE_2M,
333 [ZD_CS_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CS_CCK_RATE_5_5M, 333 [ZD_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CCK_RATE_5_5M,
334 [ZD_CS_CCK_RATE_11M] = ZD_CS_CCK|ZD_CS_CCK_RATE_11M, 334 [ZD_CCK_RATE_11M] = ZD_CS_CCK|ZD_CCK_RATE_11M,
335 [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M, 335 [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M,
336 [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M, 336 [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M,
337 [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M, 337 [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M,
@@ -343,19 +343,19 @@ static u8 cs_typed_rate(u8 cs_rate)
343 }; 343 };
344 344
345 ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f); 345 ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f);
346 return typed_rates[cs_rate & ZD_CS_RATE_MASK]; 346 return typed_rates[zd_rate & ZD_CS_RATE_MASK];
347} 347}
348 348
349/* Fallback to lowest rate, if rate is unknown. */ 349/* Fallback to lowest rate, if rate is unknown. */
350static u8 rate_to_cs_rate(u8 rate) 350static u8 rate_to_zd_rate(u8 rate)
351{ 351{
352 switch (rate) { 352 switch (rate) {
353 case IEEE80211_CCK_RATE_2MB: 353 case IEEE80211_CCK_RATE_2MB:
354 return ZD_CS_CCK_RATE_2M; 354 return ZD_CCK_RATE_2M;
355 case IEEE80211_CCK_RATE_5MB: 355 case IEEE80211_CCK_RATE_5MB:
356 return ZD_CS_CCK_RATE_5_5M; 356 return ZD_CCK_RATE_5_5M;
357 case IEEE80211_CCK_RATE_11MB: 357 case IEEE80211_CCK_RATE_11MB:
358 return ZD_CS_CCK_RATE_11M; 358 return ZD_CCK_RATE_11M;
359 case IEEE80211_OFDM_RATE_6MB: 359 case IEEE80211_OFDM_RATE_6MB:
360 return ZD_OFDM_RATE_6M; 360 return ZD_OFDM_RATE_6M;
361 case IEEE80211_OFDM_RATE_9MB: 361 case IEEE80211_OFDM_RATE_9MB:
@@ -373,7 +373,7 @@ static u8 rate_to_cs_rate(u8 rate)
373 case IEEE80211_OFDM_RATE_54MB: 373 case IEEE80211_OFDM_RATE_54MB:
374 return ZD_OFDM_RATE_54M; 374 return ZD_OFDM_RATE_54M;
375 } 375 }
376 return ZD_CS_CCK_RATE_1M; 376 return ZD_CCK_RATE_1M;
377} 377}
378 378
379int zd_mac_set_mode(struct zd_mac *mac, u32 mode) 379int zd_mac_set_mode(struct zd_mac *mac, u32 mode)
@@ -474,13 +474,13 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range)
474 return 0; 474 return 0;
475} 475}
476 476
477static int zd_calc_tx_length_us(u8 *service, u8 cs_rate, u16 tx_length) 477static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length)
478{ 478{
479 static const u8 rate_divisor[] = { 479 static const u8 rate_divisor[] = {
480 [ZD_CS_CCK_RATE_1M] = 1, 480 [ZD_CCK_RATE_1M] = 1,
481 [ZD_CS_CCK_RATE_2M] = 2, 481 [ZD_CCK_RATE_2M] = 2,
482 [ZD_CS_CCK_RATE_5_5M] = 11, /* bits must be doubled */ 482 [ZD_CCK_RATE_5_5M] = 11, /* bits must be doubled */
483 [ZD_CS_CCK_RATE_11M] = 11, 483 [ZD_CCK_RATE_11M] = 11,
484 [ZD_OFDM_RATE_6M] = 6, 484 [ZD_OFDM_RATE_6M] = 6,
485 [ZD_OFDM_RATE_9M] = 9, 485 [ZD_OFDM_RATE_9M] = 9,
486 [ZD_OFDM_RATE_12M] = 12, 486 [ZD_OFDM_RATE_12M] = 12,
@@ -494,15 +494,15 @@ static int zd_calc_tx_length_us(u8 *service, u8 cs_rate, u16 tx_length)
494 u32 bits = (u32)tx_length * 8; 494 u32 bits = (u32)tx_length * 8;
495 u32 divisor; 495 u32 divisor;
496 496
497 divisor = rate_divisor[cs_rate]; 497 divisor = rate_divisor[zd_rate];
498 if (divisor == 0) 498 if (divisor == 0)
499 return -EINVAL; 499 return -EINVAL;
500 500
501 switch (cs_rate) { 501 switch (zd_rate) {
502 case ZD_CS_CCK_RATE_5_5M: 502 case ZD_CCK_RATE_5_5M:
503 bits = (2*bits) + 10; /* round up to the next integer */ 503 bits = (2*bits) + 10; /* round up to the next integer */
504 break; 504 break;
505 case ZD_CS_CCK_RATE_11M: 505 case ZD_CCK_RATE_11M:
506 if (service) { 506 if (service) {
507 u32 t = bits % 11; 507 u32 t = bits % 11;
508 *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION; 508 *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION;
@@ -522,16 +522,16 @@ enum {
522 R2M_11A = 0x02, 522 R2M_11A = 0x02,
523}; 523};
524 524
525static u8 cs_rate_to_modulation(u8 cs_rate, int flags) 525static u8 zd_rate_to_modulation(u8 zd_rate, int flags)
526{ 526{
527 u8 modulation; 527 u8 modulation;
528 528
529 modulation = cs_typed_rate(cs_rate); 529 modulation = zd_rate_typed(zd_rate);
530 if (flags & R2M_SHORT_PREAMBLE) { 530 if (flags & R2M_SHORT_PREAMBLE) {
531 switch (ZD_CS_RATE(modulation)) { 531 switch (ZD_CS_RATE(modulation)) {
532 case ZD_CS_CCK_RATE_2M: 532 case ZD_CCK_RATE_2M:
533 case ZD_CS_CCK_RATE_5_5M: 533 case ZD_CCK_RATE_5_5M:
534 case ZD_CS_CCK_RATE_11M: 534 case ZD_CCK_RATE_11M:
535 modulation |= ZD_CS_CCK_PREA_SHORT; 535 modulation |= ZD_CS_CCK_PREA_SHORT;
536 return modulation; 536 return modulation;
537 } 537 }
@@ -548,15 +548,15 @@ static void cs_set_modulation(struct zd_mac *mac, struct zd_ctrlset *cs,
548{ 548{
549 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); 549 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev);
550 u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl)); 550 u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl));
551 u8 rate, cs_rate; 551 u8 rate, zd_rate;
552 int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0; 552 int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0;
553 553
554 /* FIXME: 802.11a? short preamble? */ 554 /* FIXME: 802.11a? short preamble? */
555 rate = ieee80211softmac_suggest_txrate(softmac, 555 rate = ieee80211softmac_suggest_txrate(softmac,
556 is_multicast_ether_addr(hdr->addr1), is_mgt); 556 is_multicast_ether_addr(hdr->addr1), is_mgt);
557 557
558 cs_rate = rate_to_cs_rate(rate); 558 zd_rate = rate_to_zd_rate(rate);
559 cs->modulation = cs_rate_to_modulation(cs_rate, 0); 559 cs->modulation = zd_rate_to_modulation(zd_rate, 0);
560} 560}
561 561
562static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, 562static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 3feb292651df..3c86578150b3 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -48,10 +48,11 @@ struct zd_ctrlset {
48#define ZD_CS_CCK 0x00 48#define ZD_CS_CCK 0x00
49#define ZD_CS_OFDM 0x10 49#define ZD_CS_OFDM 0x10
50 50
51#define ZD_CS_CCK_RATE_1M 0x00 51/* These are referred to as zd_rates */
52#define ZD_CS_CCK_RATE_2M 0x01 52#define ZD_CCK_RATE_1M 0x00
53#define ZD_CS_CCK_RATE_5_5M 0x02 53#define ZD_CCK_RATE_2M 0x01
54#define ZD_CS_CCK_RATE_11M 0x03 54#define ZD_CCK_RATE_5_5M 0x02
55#define ZD_CCK_RATE_11M 0x03
55/* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*. 56/* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*.
56 */ 57 */
57 58