Question

By default, fast frames are enabled in ath5k. (http://wireless.kernel.org/en/users/Drivers/ath5k) I have found the macro which disables it

#define AR5K_EEPROM_FF_DIS(_v)      (((_v) >> 2) & 0x1

The question is what do I do with it? Do I replace the above line with

#define AR5K_EEPROM_FF_DIS(_v)  1

?

Do I compile it passing some parameter?

The bit-shift expression confuses me. Is _v a variable?

The question is more general as to how to deal with such macros in drivers. I've seen them in other codes too and always got confused.

Was it helpful?

Solution

Ok, I try to explain with a simplified example

#include <stdio.h>

/* Just for print in binary mode */
char *chartobin(unsigned char c)
{
    static char a[9];
    int i;

    for (i = 0; i < 8; i++)
          a[7 - i] = (c & (1 << i)) == (1 << i) ? '1' : '0';
    a[8] = '\0';
    return a;
}

int main(void)
{
    unsigned char u = 0xf;

    printf("%s\n", chartobin(u)); 
    u >>= 2; // Shift bits 2 positions (to the right)
    printf("%s\n", chartobin(u));       
    printf("%s\n", chartobin(u & 0x1)); // Check if the last bit is on

    return 0;
}

Output:

00001111
00000011
00000001

Do I replace the above line with #define AR5K_EEPROM_FF_DIS(_v) 1?

Nooooo!!

If you initialize u with 0xb instead of 0xf you get:

00001011
00000010
00000000

As you can see (((_v) >> 2) & 0x1 != 1

OTHER TIPS

Fast frames are not enabled or used on ath5k. It's a feature allowing the card to send multiple frames at once (think of it as an early version of 11n frame aggregation) that's implemented on MadWiFi and their proprietary drivers and can only be used with an Access Point that also supports it. What you see there is a flag stored at the device's EEPROM that instructs the driver if fast frames can be used or not, that macro you refer to just checks if that flag is set. You can modify the header file to always return 1 but that wouldn't make any difference, the driver never uses that information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top