pfe: pfe_vwd_vap_up should honor the MAC address sent from cmm.
When adding an interface, cmm sends a command to pfe that includes
the mac address of the interface if it is not part of a bridge, or
the mac address of the bridge if it's a member of a bridge.
pfe_vwd_vap_up ignores the mac address sent by cmm, and always uses
the address from the interface. So when a link is cycled down / up,
pfe records the wrong mac address, causing the hardware FE to send
traffic up the linux stack.
Restarting hostapd cycles the link, leading to reduced upload
performance observed in b/23157318.
Change-Id: I732a116b76179a189a51fb58ab1bf6581e2483ce
diff --git a/cmm/src/module_wifi.c b/cmm/src/module_wifi.c
index 1984d84..d887ec0 100644
--- a/cmm/src/module_wifi.c
+++ b/cmm/src/module_wifi.c
@@ -124,6 +124,7 @@
cmd.ifindex = itf->ifindex;
memcpy( cmd.ifname, itf->ifname, 12);
memcpy( cmd.macaddr, itf->macaddr, 6);
+ cmd.cmd_flags |= VWD_CMD_MAC_VALID;
cmd.vap_id = itf->wifi_if->vapid;
if (itf->wifi_if->direct_path_rx) {
diff --git a/cmm/src/module_wifi.h b/cmm/src/module_wifi.h
index 9037e25..8a64f14 100644
--- a/cmm/src/module_wifi.h
+++ b/cmm/src/module_wifi.h
@@ -32,6 +32,7 @@
uint16_t cmd_flags;
#define VWD_CMD_ENABLE_DIRECT_PATH_RX (1 << 0)
#define VWD_CMD_ENABLE_DIRECT_PATH_TX (1 << 1)
+#define VWD_CMD_MAC_VALID (1 << 2)
char ifname[12];
u_int8_t macaddr[6];
} __attribute__((__packed__)) vwd_cmd_t;
diff --git a/pfe_ctrl/pfe_vwd.c b/pfe_ctrl/pfe_vwd.c
index f719df7..2f402be 100644
--- a/pfe_ctrl/pfe_vwd.c
+++ b/pfe_ctrl/pfe_vwd.c
@@ -2202,7 +2202,14 @@
vap->direct_rx_path = (cmd->cmd_flags & VAP_CMD_ENABLE_DIRECT_PATH_RX) ? 1 : 0;
vap->direct_tx_path = (cmd->cmd_flags & VAP_CMD_ENABLE_DIRECT_PATH_TX) ? 1 : 0;
memcpy(vap->ifname, wifi_dev->name, 12);
- memcpy(vap->macaddr, wifi_dev->dev_addr, 6);
+ /*
+ * vap_cmd_s' sent from cmm will have VWD_CMD_MAC_VALID set.
+ */
+ if (cmd->cmd_flags & VAP_CMD_MAC_VALID) {
+ memcpy(vap->macaddr, cmd->macaddr, 6);
+ } else {
+ memcpy(vap->macaddr, wifi_dev->dev_addr, 6);
+ }
vap->wifi_dev = wifi_dev;
vap->dev = dev;
diff --git a/pfe_ctrl/pfe_vwd.h b/pfe_ctrl/pfe_vwd.h
index 5dbf79b..a55d19a 100644
--- a/pfe_ctrl/pfe_vwd.h
+++ b/pfe_ctrl/pfe_vwd.h
@@ -69,6 +69,7 @@
unsigned short cmd_flags;
#define VAP_CMD_ENABLE_DIRECT_PATH_RX (1 << 0)
#define VAP_CMD_ENABLE_DIRECT_PATH_TX (1 << 1)
+#define VAP_CMD_MAC_VALID (1 << 2)
unsigned char ifname[12];
unsigned char macaddr[6];
};