Thursday, 25 October 2018

802 11AC - OPeration

- ACS(automatic Channel Selection)
- Adjust the HT Max MPDU based on VHT capabilities
 If VHT max MPDU is 8K or 11K, set HT AMSDU to 8K else to 4K.
- Prepare Beacon and Probe Response packets with VHT Capabilities IE and VHT Operation IE
- Start beaconing




Operation:
Channelisation - Based on the country code, channel are fetched from the regulatory domain


1. Prepare list 80MHz channels - Hard code the channel OR get them from  the frequency band of the reg domain
        - Start with chn  = lowfreq + 30.
        - chan >= lowfreq && chan =< highgreq - 30, then chan is 80Mhz
        - Hop to next freq chan+80


2. Similerly prepare list of 160Mhz channels out of freq bands.


3. If user has configured any operating channel and bandwidth, get the centre_freq1 and centre_freq2
pass the same information to FW.




1. Processing Assoc Request and Responding with Assoc Response
   
STA and AP need not have same transmitting and receving capabilities. Example STA may have 1x1 and AP may be 3x3.
Before sending assoc response to STA, assoc req needs to be parsed


A)    Intersection of Tx and Rx rates[MCS set].
     - TX MCS set of AP is intersected with RX MCS set of STA,


           TX AP       RX:STA
1SS     0-9             0-7
2SS     0-9              NA
3SS     0-9              NA


After intersection only MCS set 0-7 for 1SS is selected for transmitting frame to that STA


b) Channel width: Minimum bandwidth value of AP bandwidth and STA bandwidth is selected as bandwidth for Rx/Tx with that STA





Network Driver - NIC commnunication( Data Path)

How to Communicate between Driver and NIC

 

http://www.cubrid.org/blog/dev-platform/understanding-tcp-ip-network-stack/

Communication between a driver and the NIC is the bottom of the stack and most people do not care about it. However, the NIC is executing more and more tasks to solve the performance issue. Understanding the basic operation scheme will help you understand the additional technology.
A driver and the NIC asynchronously communicate. First, a driver requests packet transmission (call) and the CPU performs another task without waiting for the response. And then the NIC sends packets and notifies the CPU of that, the driver returns the received packets (returns the result). Like packet transmission, packet receiving is asynchronous. First, a driver requests packet receiving and the CPU performs another task (call). Then, the NIC receives packets and notifies the CPU of that, and the driver processes the received packets received (returns the result).
Therefore, a space to save the request and the response is necessary. In most cases, the NIC uses the ring structure. The ring is similar to the common queue structure. With the fixed number of entries, one entry saves one request data or one response data. The entries are sequentially used in turn. The name "ring" is generally used since the fixed entries are reused in turn.
As following the packet transmission procedure shown in the following Figure 8, you will see how the ring is used.

 


The driver receives packets from the upper layer and creates the send descriptor that the NIC can understand. The send descriptor includes the packet size and the memory address by default. As the NIC needs the physical address to access the memory, the driver should change the virtual address of the packets to the physical address. Then, it adds the send descriptor to the TX ring (1). The TX ring is the send descriptor ring.
Next, it notifies the NIC of the new request (2). The driver directly writes the data to a specific NIC memory address. In this way, Programmed I/O (PIO) is the data transmission method in which the CPU directly sends data to the device.
The notified NIC gets the send descriptor of the TX ring from the host memory (3). Since the device directly accesses the memory without intervention of the CPU, the access is called Direct Memory Access (DMA).
After getting the send descriptor, the NIC determines the packet address and the size and then gets the actual packets from the host memory (4). With the checksum offload, the NIC computes the checksum when the NIC gets the packet data from the memory. Therefore, overhead rarely occurs.
The NIC sends packets (5) and then writes the number of packets that are sent to the host memory (6). Then, it sends an interrupt (7). The driver reads the number of packets that are sent and then returns the packets that have been sent so far.
In the following Figure 9, you will see the procedure of receiving packets.




First the driver allocates the host memory buffer for receiving packets and then creates the receive descriptor. The receive descriptor includes the buffer size and the memory address by default. Like the send descriptor, it saves the physical address that the DMA uses in the receive descriptor. Then, it adds the receive descriptor to the RX ring (1). It is the receive request and the RX ring is the receive request ring.
Through the PIO, the driver notifies that there is a new descriptor in the NIC (2). The NIC gets the new descriptor of the RX ring. And then it saves the size and location of the buffer included in the descriptor to the NIC memory (3).
After the packets have been received (4), the NIC sends the packets to the host memory buffer (5). If the checksum offload function is existing, the NIC computes the checksum at this time. The actual size of received packets, the checksum result, and any other information are saved in the separate ring (the receive return ring) (6). The receive return ring saves the result of processing the receive request, i.e., the response. And then the NIC sends an interrupt (7). The driver gets packet information from the receive return ring and processes the received packets. If necessary, it allocates new memory buffer and repeats Step (1) and Step (2).
To tune the stack, most people say that the ring and interrupt setting should be adjusted. When the TX ring is large, a lot of send requests can be made at once. When the RX ring is large, a lot of packet receives can be done at once. A large ring is useful for the workload that has a huge burst of packet transmission/receiving. In most cases, the NIC uses a timer to reduce the number of interrupts since the CPU may suffer from large overhead to process interrupts. To avoid flooding the host system with too many interrupts, interrupts are collected and sent regularly(interrupt coalescing) while sending and receiving the packets

RSS and RPS

 http://balodeamit.blogspot.in/2013/10/receive-side-scaling-and-receive-packet.html

 

Network commands

              Mutlicast - Mutlicast Teset using iperf
                    STA DUT
                           - mcsctl -s br-lan route flood
                           - echo 0 > /sys/devices/virtual/net/br-lan/bridge/multicast_snooping
                    STA back end - run iperf server
                           - route print
                           - route add 224.0.0.0 MASK 240.0.0.0 IF <if id> <ifterface ip(192.168.1.40>
                           - route add 225.0.0.0 MASK 255.0.0.0 IF <if id> <ifterface ip(192.168.1.40>
                           - make sure above routes are added using 'route print'
                           - iperf -s -u -i 1 -B <mcast group add(225.0.0.10)>
                    AP Back end - run iperf client
                           -  Enable mcast enhancement:
                               - iwpriv ath0 mcastenhance 5
                           -  From AP Dut console check that mcast group ip(225.0.0.100) is updated.
                               - mcsctl -g br-lan mdbtbl 20
                           -  iperf -c <multicast group ip(225.0.0.10)> -u -i 1 -t 100 -B <interface ip(192.168.1.55> -b 5M
                           -  Make sure server is receiving the traffic.

Ethernet Header:

6 bytes: Dest mac address
6 bytes: src mac address
2 bytes: Type

IP Header:


Friday, 25 May 2018

802 11AC - OPeration

- ACS(automatic Channel Selection)
- Adjust the HT Max MPDU based on VHT capabilities
 If VHT max MPDU is 8K or 11K, set HT AMSDU to 8K else to 4K.
- Prepare Beacon and Probe Response packets with VHT Capabilities IE and VHT Operation IE
- Start beaconing




Operation:
Channelisation - Based on the country code, channel are fetched from the regulatory domain


1. Prepare list 80MHz channels - Hard code the channel OR get them from  the frequency band of the reg domain
        - Start with chn  = lowfreq + 30.
        - chan >= lowfreq && chan =< highgreq - 30, then chan is 80Mhz
        - Hop to next freq chan+80


2. Similerly prepare list of 160Mhz channels out of freq bands.


3. If user has configured any operating channel and bandwidth, get the centre_freq1 and centre_freq2
pass the same information to FW.




1. Processing Assoc Request and Responding with Assoc Response
   
STA and AP need not have same transmitting and receving capabilities. Example STA may have 1x1 and AP may be 3x3.
Before sending assoc response to STA, assoc req needs to be parsed


A)    Intersection of Tx and Rx rates[MCS set].
     - TX MCS set of AP is intersected with RX MCS set of STA,


           TX AP       RX:STA
1SS     0-9             0-7
2SS     0-9              NA
3SS     0-9              NA


After intersection only MCS set 0-7 for 1SS is selected for transmitting frame to that STA


b) Channel width: Minimum bandwidth value of AP bandwidth and STA bandwidth is selected as bandwidth for Rx/Tx with that STA





Wednesday, 9 May 2018

NAPI Driver

NAPI driver:

netif_napi_add(netdev, contex,poll api
napi_enable
napi_schedule
https://wiki.linuxfoundation.org/networking/napi


Tuesday, 24 April 2018

802.11w Protected Management Frames

Protected Management Frames is a feature to protect some types of management frames like
deauthorization, disassociation and action frames. This feature prevents attackers from sending
plain deauthorization/disassociation frames to disrupt or tear down a connection/association. PMF
is a Wi-Fi Alliance specification based on IEEE 802.11w

The AP is configured with SSID, encryption type, authentication type, and PMF capability bit in
the RSN IE capability field. Based on those settings, STAs associating with this AP will perform
PMF association and get unicast/broadcast/IGTK (Integrated Group Temporal Key) keys. IGTK is
used for broadcast, deauthorization, and disassociation frames.
Most of the PMF functionality is handled in hostapd. As part of PMF, new key management
algorithms (SHA-256 and SHA-256-PSK) are introduced.

hostapd is configured with PMF settings through the pmf.conf file. After successfully parsing
pmf.conf, hostapd sends config ioctls down to WLAN driver. The Linux shim processes the config
ioctls from hostapd and starts the AP with PMF settings in beacons. PMF STA associate with the
AP and both AP and STA derive necessary keys.
The key used for protecting unicast frames is used for protection of management frames as well.

Embedded

http://www.plantation-productions.com/Webster/www.artofasm.com/Linux/HTML/MemoryArchitecturea2.html

Direct cache mapping - One memory block can be mapped to only one of the cache block and it is possible that more than one memory block mapped to the same cache block. It is very inefficient because same cache mapped memory block will evict another memory block,
Not more than one same cache mapped memory block can be in cache memory.

2 way associative  - 2 cache lines(blocks) per set. One memory block is cached to any one set of the cache. Within that that set it can be mapped to any of the cache block.
2 memory blocks mapped to the same set, need not have to evict each other. They can exist in cache at the same time.

4 way associative - 4 cache lines(blocks) per set.


Programme Address Space:

Mainly

stack - Stores local variables of the functions, functional parameters and return pointer.
heap - dynamically allocated memory
bss - Uninitialised static and global variables, filled with zeroes
data - initialised static and global vaiables
text - programme code and initialised strings variable or constants

https://manybutfinite.com/post/anatomy-of-a-program-in-memory/


Questions:
1) 96 interuupts are available in the system. Storethe IRQ number in bit mask
2) Write programm to return highest available interrupt while allocating the interrupt.

Monday, 23 April 2018

Wifi Data TX path

Wifi TX for AP mode :

Linux stack passes ethernet packet.

1. xmit( netdev, skb) --- This is call back api of the wifi driver .
   - Linux stack calls this callback api to send packet through wifi driver
   - Extract the driver specific pointer from netdev.

2. Check that is skb has clones and remove any clones to it
    skb = skb_unshare(skb);

3. Check available header length, driver needs to add its header needed for host to target packet tradnfer
    skb_headroom()  --- return the available headroom
    skb = skb_realloc_headroom(skb, head_length_needed)
 

4. Check is the frame multicast packet
        - struct eth_head *eth = (struct eth_head *)skb->data;
          eth->destination[0] = 0x01 --- > it is multicast packet

5. It it is not multicast packet, find the STA node that is associated with dest mac address.
  -     AP maintains node table of all the connected STA devices.
  -     If STA node is not found, then dest mac address is unknown mac and packet is discarded, Who fress the SKB here ??

STA devices connect and disconnect at random interval of time, access to node table needs to be protected. In tx path, node table is accessed only for read the table. rw_lock can be used to protect it here.

Read_Write lock: It allows multiple readers at the same but only one writer. Example, if reader has taken the lock, another reader can also take the lock, second reader will not get blocked till first reader unlocks it. Both can access the critical section the same time.
 read_lock(rw_lock)  ;

If writer tries to take the lock and if there are no readers at the same time, it will get the lock. In case there are any readers holding the lock, writer has to wait till all reader unlock the lock.
Wait operation is similer to spin_lock().

write_lock(rw_lock);
   
6. Classify the packet
 - Different types of packet are sent over ehternet,
   - IPv4
   - IPv6
   - EAPOL
   - ARP

   From  the ethernet header extract the type.
   For IPV4 packet types need to extract the "Type of Service" DSCP value from IP headet of  the packet.
  - struct ipheader *iph = (uint8 *)skb->data + sizeof(ether_header);
     iph->tos  - is the tid of the packet.
 Each tid falls into to any one of the below ACs
 Access Catogaries - Back Ground ----- lowest priority
                                 Best Effort
                                  Video
                                  Voice --- highetst priority

  Each SKB has some space left for control buffer(cb portion) of 48 bytes. This space can be used by each layer to set status of the packet and to set flags that describe the packet.

Tid of the packet is set in cb portion of the skb



7. DHCP packet - Check UDP source port as 63 or 64

Extended Access Point: Provide connectivity to remote access Point











    

Monday, 26 February 2018

vedapuram



https://wego.here.com/directions/mix//Vedapuram,-Old-Kesare,-Kamanakerehundi-Road,-570001-Mysore:e-eyJuYW1lIjoiVmVkYXB1cmFtIiwiYWRkcmVzcyI6Ik9sZCBLZXNhcmUsIEthbWFuYWtlcmVodW5kaSBSb2FkLCBNeXNvcmUsIEthcm5hdGFrYSA1NzAwMDEiLCJsYXRpdHVkZSI6MTIuMzUzNDU5MDQ1NDI5LCJsb25naXR1ZGUiOjc2LjY4MjY4MjAzNzM1NCwicHJvdmlkZXJOYW1lIjoiZmFjZWJvb2siLCJwcm92aWRlcklkIjoxNzQzMTIwODMxNTA3MjR9?map=12.34665,76.68481,15,normal&fb_locale=en_US

https://www.google.co.in/maps/search/Kamanakerehundi+Road/@12.3526878,76.6890273,1586m/data=!3m1!1e3

https://www.facebook.com/vedapuram/

30X40:15.8 lacs