Skip to content

Commit

Permalink
add RSSI for all platforms and Frame Control (supporting Raspberry PI…
Browse files Browse the repository at this point in the history
… only for now)
  • Loading branch information
mzakharo committed Jun 15, 2020
1 parent c74d78b commit 7e3f9f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/csi.ucode.bcm43455c0.7_45_189.patch
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
---
> orx 0, 2, 0x1, [RX_HDR_RxStatus1], [RX_HDR_RxStatus1]
> orx 0, 1, 0x0, [RX_HDR_RxStatus2], [RX_HDR_RxStatus2]
4158a4291,4378
4158a4291,4379
> je DUMP_CSI, 0, csi_end+
> #define ACPHY_TBL_ID_CORE0CHANESTTBL 73
> #define ACPHY_TBL_ID_CORE1CHANESTTBL 105
Expand Down Expand Up @@ -359,6 +359,7 @@
> mov [SRC_MAC_CACHE_1], [1,off5]
> mov [SRC_MAC_CACHE_2], [2,off5]
> mov [SEQ_NUM_CACHE], [3,off5]
> and [3,off1], 0xff, [4,off5]
> not_last_chunk_skip_mac:
> mov RX_HDR_BASE + RXE_RXHDR_LEN, SPR_RXE_RXHDR_OFFSET
> calls L900
Expand Down
11 changes: 9 additions & 2 deletions src/csi_extractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ struct wlc_d11rxhdr {

struct csi_udp_frame {
struct ethernet_ip_udp_header hdrs;
uint32 kk1;
uint16 kk1;
int8 rssi;
uint8 fc; //frame control
uint8 SrcMac[6];
uint16 seqCnt;
uint16 csiconf;
Expand All @@ -148,6 +150,7 @@ struct int14 {signed int val:14;} __attribute__((packed));
uint16 missing_csi_frames = 0;
uint16 inserted_csi_values = 0;
struct sk_buff *p_csi = 0;
int8 last_rssi = 0;

void
create_new_csi_frame(struct wl_info *wl, uint16 csiconf, int length)
Expand All @@ -161,7 +164,9 @@ create_new_csi_frame(struct wl_info *wl, uint16 csiconf, int length)
// fill header
struct csi_udp_frame *udpfrm = (struct csi_udp_frame *) p_csi->data;
// add magic bytes, csi config and chanspec to new udp frame
udpfrm->kk1 = 0x11111111;
udpfrm->kk1 = 0x1111;
udpfrm->rssi = last_rssi;
udpfrm->fc = 0;
udpfrm->seqCnt = 0;
udpfrm->csiconf = csiconf;
udpfrm->chanspec = get_chanspec(wl->wlc);
Expand Down Expand Up @@ -253,6 +258,7 @@ process_frame_hook(struct sk_buff *p, struct wlc_d11rxhdr *wlc_rxhdr, struct wlc
#else
memcpy(udpfrm->SrcMac, &(ucodecsifrm->csi[tones]), sizeof(udpfrm->SrcMac)); // last csifrm also contains SrcMac
udpfrm->seqCnt = *((uint16*)(&(ucodecsifrm->csi[tones]))+(sizeof(udpfrm->SrcMac)>>1)); // last csifrm also contains seqN
udpfrm->fc = (*((uint16*)(&(ucodecsifrm->csi[tones]))+(sizeof(udpfrm->SrcMac)>>1)+1)); // last csifrm also contains frame control field
#endif
p_csi->len = sizeof(struct csi_udp_frame) + inserted_csi_values * sizeof(uint32);
skb_pull(p_csi, sizeof(struct ethernet_ip_udp_header));
Expand All @@ -266,6 +272,7 @@ process_frame_hook(struct sk_buff *p, struct wlc_d11rxhdr *wlc_rxhdr, struct wlc

wlc_rxhdr->tsf_l = tsf_l;
wlc_phy_rssi_compute(wlc_hw->band->pi, wlc_rxhdr);
last_rssi = wlc_rxhdr->rssi;
wlc_recv(wlc_hw->wlc, p);
}

Expand Down

8 comments on commit 7e3f9f7

@haochenku
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. What is the meaning of adding this line 'and [3,off1], 0xff, [4,off5]'?

@mzakharo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[3,off1] is the Frame Control byte.

@haochenku
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mzakharo Thank you so much for your quick reply!! What is the purpose of framecontrol here? Originally, I was thinking the change of 'last_rssi = wlc_rxhdr->rssi' should do this job, but it seems some additional framecontrol is needed, any reason for this? If we do not need to report framecontrol information to user space, then can we ignore the changed line of 'and [3,off1], 0xff, [4,off5]'?
Another question is that could we add this line and corresponding defination of 'last_rssi = wlc_rxhdr->rssi' to BCM 4339?

@mzakharo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frame control byte and rssi have nothing to do with each other. just lumped together in one CL. you can cherry pick as you please

@haochenku
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mzakharo Thank you a lot for the reply. I have following two questions:

  1. adding frame control is because due to the fact that the sequence number is not accurate? Is it general for bcm4339 and bcm4358?
  2. currently rssi is last rssi, is it possible to get the current rssi to remove the delay by one sample?

Thanks a lot.

@mzakharo
Copy link
Contributor Author

@mzakharo mzakharo commented on 7e3f9f7 Jul 8, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haochenku
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @mzakharo , I checked the rssi on Nexus 6P. They worked. But, I found that the RSSI on two cores are different. Should they be same value?
image

@mzakharo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never looked at RSSI of anything but core 0. However, I cannot explain this value being different on different cores. 'last_rssi' should not get changed in between switching of cores. From my understanding, the D11 microcode should just loop through all cores back to back without getting to the section that updates last_rssi until the next new packet.

Please sign in to comment.