Merge "msm: ipa3: support AP+STA IPA stats"

This commit is contained in:
Linux Build Service Account 2016-12-20 14:04:24 -08:00 committed by Gerrit - the friendly Code Review server
commit 164220fbcd
10 changed files with 333 additions and 20 deletions

View file

@ -1633,6 +1633,25 @@ u16 ipa_get_smem_restr_bytes(void)
}
EXPORT_SYMBOL(ipa_get_smem_restr_bytes);
/**
* ipa_broadcast_wdi_quota_reach_ind() - quota reach
* @uint32_t fid: [in] input netdev ID
* @uint64_t num_bytes: [in] used bytes
*
* Returns: 0 on success, negative on failure
*/
int ipa_broadcast_wdi_quota_reach_ind(uint32_t fid,
uint64_t num_bytes)
{
int ret;
IPA_API_DISPATCH_RETURN(ipa_broadcast_wdi_quota_reach_ind,
fid, num_bytes);
return ret;
}
EXPORT_SYMBOL(ipa_broadcast_wdi_quota_reach_ind);
/**
* ipa_uc_wdi_get_dbpa() - To retrieve
* doorbell physical address of wlan pipes

View file

@ -183,6 +183,9 @@ struct ipa_api_controller {
u16 (*ipa_get_smem_restr_bytes)(void);
int (*ipa_broadcast_wdi_quota_reach_ind)(uint32_t fid,
uint64_t num_bytes);
int (*ipa_uc_wdi_get_dbpa)(struct ipa_wdi_db_params *out);
int (*ipa_uc_reg_rdyCB)(struct ipa_wdi_uc_ready_params *param);

View file

@ -963,6 +963,10 @@ struct ipa3_uc_wdi_ctx {
struct IpaHwStatsWDIInfoData_t *wdi_uc_stats_mmio;
void *priv;
ipa_uc_ready_cb uc_ready_cb;
/* for AP+STA stats update */
#ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN
ipa_wdi_meter_notifier_cb stats_notify;
#endif
};
/**
@ -1674,6 +1678,7 @@ int ipa3_resume_wdi_pipe(u32 clnt_hdl);
int ipa3_suspend_wdi_pipe(u32 clnt_hdl);
int ipa3_get_wdi_stats(struct IpaHwStatsWDIInfoData_t *stats);
u16 ipa3_get_smem_restr_bytes(void);
int ipa3_broadcast_wdi_quota_reach_ind(uint32_t fid, uint64_t num_bytes);
int ipa3_setup_uc_ntn_pipes(struct ipa_ntn_conn_in_params *in,
ipa_notify_cb notify, void *priv, u8 hdr_len,
struct ipa_ntn_conn_out_params *outp);
@ -1714,6 +1719,9 @@ enum ipacm_client_enum ipa3_get_client(int pipe_idx);
bool ipa3_get_client_uplink(int pipe_idx);
int ipa3_get_wlan_stats(struct ipa_get_wdi_sap_stats *wdi_sap_stats);
int ipa3_set_wlan_quota(struct ipa_set_wifi_quota *wdi_quota);
/*
* IPADMA
*/

View file

@ -880,7 +880,8 @@ static void ipa3_q6_clnt_ind_cb(struct qmi_handle *handle, unsigned int msg_id,
IPAWANDBG("Quota reached indication on qmux(%d) Mbytes(%lu)\n",
qmi_ind.apn.mux_id,
(unsigned long int) qmi_ind.apn.num_Mbytes);
ipa3_broadcast_quota_reach_ind(qmi_ind.apn.mux_id);
ipa3_broadcast_quota_reach_ind(qmi_ind.apn.mux_id,
IPA_UPSTEAM_MODEM);
}
}

View file

@ -181,7 +181,8 @@ int rmnet_ipa3_poll_tethering_stats(struct wan_ioctl_poll_tethering_stats
int rmnet_ipa3_set_data_quota(struct wan_ioctl_set_data_quota *data);
void ipa3_broadcast_quota_reach_ind(uint32_t mux_id);
void ipa3_broadcast_quota_reach_ind(uint32_t mux_id,
enum ipa_upstream_type upstream_type);
int rmnet_ipa3_set_tether_client_pipe(struct wan_ioctl_set_tether_client_pipe
*data);
@ -189,6 +190,8 @@ int rmnet_ipa3_set_tether_client_pipe(struct wan_ioctl_set_tether_client_pipe
int rmnet_ipa3_query_tethering_stats(struct wan_ioctl_query_tether_stats *data,
bool reset);
int rmnet_ipa3_reset_tethering_stats(struct wan_ioctl_reset_tether_stats *data);
int ipa3_qmi_get_data_stats(struct ipa_get_data_stats_req_msg_v01 *req,
struct ipa_get_data_stats_resp_msg_v01 *resp);
@ -283,7 +286,8 @@ static inline int rmnet_ipa3_set_data_quota(
return -EPERM;
}
static inline void ipa3_broadcast_quota_reach_ind(uint32_t mux_id) { }
static inline void ipa3_broadcast_quota_reach_ind(uint32_t mux_id,
enum ipa_upstream_type upstream_type) { }
static inline int ipa3_qmi_get_data_stats(
struct ipa_get_data_stats_req_msg_v01 *req,

View file

@ -13,6 +13,7 @@
#include <linux/dmapool.h>
#include <linux/delay.h>
#include <linux/mm.h>
#include "ipa_qmi_service.h"
#define IPA_HOLB_TMR_DIS 0x0
@ -1185,6 +1186,12 @@ int ipa3_connect_wdi_pipe(struct ipa_wdi_in_params *in,
ep->client_notify = in->sys.notify;
ep->priv = in->sys.priv;
/* for AP+STA stats update */
if (in->wdi_notify)
ipa3_ctx->uc_wdi_ctx.stats_notify = in->wdi_notify;
else
IPADBG("in->wdi_notify is null\n");
if (!ep->skip_ep_cfg) {
if (ipa3_cfg_ep(ipa_ep_idx, &in->sys.ipa_ep_cfg)) {
IPAERR("fail to configure EP.\n");
@ -1276,6 +1283,12 @@ int ipa3_disconnect_wdi_pipe(u32 clnt_hdl)
IPADBG("client (ep: %d) disconnected\n", clnt_hdl);
/* for AP+STA stats update */
if (ipa3_ctx->uc_wdi_ctx.stats_notify)
ipa3_ctx->uc_wdi_ctx.stats_notify = NULL;
else
IPADBG("uc_wdi_ctx.stats_notify already null\n");
uc_timeout:
return result;
}
@ -1618,6 +1631,23 @@ uc_timeout:
return result;
}
/**
* ipa_broadcast_wdi_quota_reach_ind() - quota reach
* @uint32_t fid: [in] input netdev ID
* @uint64_t num_bytes: [in] used bytes
*
* Returns: 0 on success, negative on failure
*/
int ipa3_broadcast_wdi_quota_reach_ind(uint32_t fid,
uint64_t num_bytes)
{
IPAERR("Quota reached indication on fis(%d) Mbytes(%lu)\n",
fid,
(unsigned long int) num_bytes);
ipa3_broadcast_quota_reach_ind(0, IPA_UPSTEAM_WLAN);
return 0;
}
int ipa3_write_qmapid_wdi_pipe(u32 clnt_hdl, u8 qmap_id)
{
int result = 0;

View file

@ -1000,11 +1000,39 @@ void ipa3_set_client(int index, enum ipacm_client_enum client, bool uplink)
}
}
/* ipa3_get_wlan_stats() - get ipa wifi stats
*
* Return value: success or failure
*/
int ipa3_get_wlan_stats(struct ipa_get_wdi_sap_stats *wdi_sap_stats)
{
if (ipa3_ctx->uc_wdi_ctx.stats_notify) {
ipa3_ctx->uc_wdi_ctx.stats_notify(IPA_GET_WDI_SAP_STATS,
wdi_sap_stats);
} else {
IPAERR("uc_wdi_ctx.stats_notify NULL\n");
return -EFAULT;
}
return 0;
}
int ipa3_set_wlan_quota(struct ipa_set_wifi_quota *wdi_quota)
{
if (ipa3_ctx->uc_wdi_ctx.stats_notify) {
ipa3_ctx->uc_wdi_ctx.stats_notify(IPA_SET_WIFI_QUOTA,
wdi_quota);
} else {
IPAERR("uc_wdi_ctx.stats_notify NULL\n");
return -EFAULT;
}
return 0;
}
/**
* ipa3_get_client() - provide client mapping
* @client: client type
*
* Return value: none
* Return value: client mapping enum
*/
enum ipacm_client_enum ipa3_get_client(int pipe_idx)
{
@ -3122,6 +3150,8 @@ int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
api_ctrl->ipa_suspend_wdi_pipe = ipa3_suspend_wdi_pipe;
api_ctrl->ipa_get_wdi_stats = ipa3_get_wdi_stats;
api_ctrl->ipa_get_smem_restr_bytes = ipa3_get_smem_restr_bytes;
api_ctrl->ipa_broadcast_wdi_quota_reach_ind =
ipa3_broadcast_wdi_quota_reach_ind;
api_ctrl->ipa_uc_wdi_get_dbpa = ipa3_uc_wdi_get_dbpa;
api_ctrl->ipa_uc_reg_rdyCB = ipa3_uc_reg_rdyCB;
api_ctrl->ipa_uc_dereg_rdyCB = ipa3_uc_dereg_rdyCB;

View file

@ -52,6 +52,7 @@
#define DEFAULT_OUTSTANDING_LOW 32
#define IPA_WWAN_DEV_NAME "rmnet_ipa%d"
#define IPA_UPSTEAM_WLAN_IFACE_NAME "wlan0"
#define IPA_WWAN_RX_SOFTIRQ_THRESH 16
@ -783,6 +784,22 @@ static int find_vchannel_name_index(const char *vchannel_name)
return MAX_NUM_OF_MUX_CHANNEL;
}
static enum ipa_upstream_type find_upstream_type(const char *upstreamIface)
{
int i;
for (i = 0; i < MAX_NUM_OF_MUX_CHANNEL; i++) {
if (strcmp(rmnet_ipa3_ctx->mux_channel[i].vchannel_name,
upstreamIface) == 0)
return IPA_UPSTEAM_MODEM;
}
if (strcmp(IPA_UPSTEAM_WLAN_IFACE_NAME, upstreamIface) == 0)
return IPA_UPSTEAM_WLAN;
else
return MAX_NUM_OF_MUX_CHANNEL;
}
static int ipa3_wwan_register_to_ipa(int index)
{
struct ipa_tx_intf tx_properties = {0};
@ -2598,10 +2615,10 @@ int rmnet_ipa3_poll_tethering_stats(struct wan_ioctl_poll_tethering_stats *data)
}
/**
* rmnet_ipa_set_data_quota() - Data quota setting IOCTL handler
* rmnet_ipa_set_data_quota_modem() - Data quota setting IOCTL handler
* @data - IOCTL data
*
* This function handles WAN_IOC_SET_DATA_QUOTA.
* This function handles WAN_IOC_SET_DATA_QUOTA on modem interface.
* It translates the given interface name to the Modem MUX ID and
* sends the request of the quota to the IPA Modem driver via QMI.
*
@ -2610,12 +2627,17 @@ int rmnet_ipa3_poll_tethering_stats(struct wan_ioctl_poll_tethering_stats *data)
* -EFAULT: Invalid interface name provided
* other: See ipa_qmi_set_data_quota
*/
int rmnet_ipa3_set_data_quota(struct wan_ioctl_set_data_quota *data)
static int rmnet_ipa3_set_data_quota_modem(
struct wan_ioctl_set_data_quota *data)
{
u32 mux_id;
int index;
struct ipa_set_data_usage_quota_req_msg_v01 req;
/* stop quota */
if (!data->set_quota)
ipa3_qmi_stop_data_qouta();
index = find_vchannel_name_index(data->interface_name);
IPAWANERR("iface name %s, quota %lu\n",
data->interface_name,
@ -2639,6 +2661,64 @@ int rmnet_ipa3_set_data_quota(struct wan_ioctl_set_data_quota *data)
return ipa3_qmi_set_data_quota(&req);
}
static int rmnet_ipa3_set_data_quota_wifi(struct wan_ioctl_set_data_quota *data)
{
struct ipa_set_wifi_quota wifi_quota;
int rc = 0;
memset(&wifi_quota, 0, sizeof(struct ipa_set_wifi_quota));
wifi_quota.set_quota = data->set_quota;
wifi_quota.quota_bytes = data->quota_mbytes;
IPAWANERR("iface name %s, quota %lu\n",
data->interface_name,
(unsigned long int) data->quota_mbytes);
rc = ipa3_set_wlan_quota(&wifi_quota);
/* check if wlan-fw takes this quota-set */
if (!wifi_quota.set_valid)
rc = -EFAULT;
return rc;
}
/**
* rmnet_ipa_set_data_quota() - Data quota setting IOCTL handler
* @data - IOCTL data
*
* This function handles WAN_IOC_SET_DATA_QUOTA.
* It translates the given interface name to the Modem MUX ID and
* sends the request of the quota to the IPA Modem driver via QMI.
*
* Return codes:
* 0: Success
* -EFAULT: Invalid interface name provided
* other: See ipa_qmi_set_data_quota
*/
int rmnet_ipa3_set_data_quota(struct wan_ioctl_set_data_quota *data)
{
enum ipa_upstream_type upstream_type;
int rc = 0;
/* get IPA backhaul type */
upstream_type = find_upstream_type(data->interface_name);
if (upstream_type == IPA_UPSTEAM_MAX) {
IPAWANERR("Wrong interface_name name %s\n",
data->interface_name);
} else if (upstream_type == IPA_UPSTEAM_WLAN) {
rc = rmnet_ipa3_set_data_quota_wifi(data);
if (rc) {
IPAWANERR("set quota on wifi failed\n");
return rc;
}
} else {
rc = rmnet_ipa3_set_data_quota_modem(data);
if (rc) {
IPAWANERR("set quota on modem failed\n");
return rc;
}
}
return rc;
}
/* rmnet_ipa_set_tether_client_pipe() -
* @data - IOCTL data
*
@ -2686,8 +2766,61 @@ int rmnet_ipa3_set_tether_client_pipe(
return 0;
}
int rmnet_ipa3_query_tethering_stats(struct wan_ioctl_query_tether_stats *data,
bool reset)
static int rmnet_ipa3_query_tethering_stats_wifi(
struct wan_ioctl_query_tether_stats *data, bool reset)
{
struct ipa_get_wdi_sap_stats *sap_stats;
int rc;
sap_stats = kzalloc(sizeof(struct ipa_get_wdi_sap_stats),
GFP_KERNEL);
if (!sap_stats) {
IPAWANERR("Can't allocate memory for stats message\n");
return -ENOMEM;
}
memset(sap_stats, 0, sizeof(struct ipa_get_wdi_sap_stats));
sap_stats->reset_stats = reset;
IPAWANDBG("reset the pipe stats %d\n", sap_stats->reset_stats);
rc = ipa3_get_wlan_stats(sap_stats);
if (rc) {
IPAWANERR("can't get ipa3_get_wlan_stats\n");
kfree(sap_stats);
return rc;
} else if (reset) {
kfree(sap_stats);
return 0;
}
if (sap_stats->stats_valid) {
data->ipv4_tx_packets = sap_stats->ipv4_tx_packets;
data->ipv4_tx_bytes = sap_stats->ipv4_tx_bytes;
data->ipv4_rx_packets = sap_stats->ipv4_rx_packets;
data->ipv4_rx_bytes = sap_stats->ipv4_rx_bytes;
data->ipv6_tx_packets = sap_stats->ipv6_tx_packets;
data->ipv6_tx_bytes = sap_stats->ipv6_tx_bytes;
data->ipv6_rx_packets = sap_stats->ipv6_rx_packets;
data->ipv6_rx_bytes = sap_stats->ipv6_rx_bytes;
}
IPAWANDBG("v4_rx_p(%lu) v6_rx_p(%lu) v4_rx_b(%lu) v6_rx_b(%lu)\n",
(unsigned long int) data->ipv4_rx_packets,
(unsigned long int) data->ipv6_rx_packets,
(unsigned long int) data->ipv4_rx_bytes,
(unsigned long int) data->ipv6_rx_bytes);
IPAWANDBG("tx_p_v4(%lu)v6(%lu)tx_b_v4(%lu) v6(%lu)\n",
(unsigned long int) data->ipv4_tx_packets,
(unsigned long int) data->ipv6_tx_packets,
(unsigned long int) data->ipv4_tx_bytes,
(unsigned long int) data->ipv6_tx_bytes);
kfree(sap_stats);
return rc;
}
static int rmnet_ipa3_query_tethering_stats_modem(
struct wan_ioctl_query_tether_stats *data, bool reset)
{
struct ipa_get_data_stats_req_msg_v01 *req;
struct ipa_get_data_stats_resp_msg_v01 *resp;
@ -2774,7 +2907,7 @@ int rmnet_ipa3_query_tethering_stats(struct wan_ioctl_query_tether_stats *data,
}
}
}
IPAWANDBG_LOW("v4_rx_p(%lu) v6_rx_p(%lu) v4_rx_b(%lu) v6_rx_b(%lu)\n",
IPAWANDBG("v4_rx_p(%lu) v6_rx_p(%lu) v4_rx_b(%lu) v6_rx_b(%lu)\n",
(unsigned long int) data->ipv4_rx_packets,
(unsigned long int) data->ipv6_rx_packets,
(unsigned long int) data->ipv4_rx_bytes,
@ -2824,7 +2957,7 @@ int rmnet_ipa3_query_tethering_stats(struct wan_ioctl_query_tether_stats *data,
}
}
}
IPAWANDBG_LOW("tx_p_v4(%lu)v6(%lu)tx_b_v4(%lu) v6(%lu)\n",
IPAWANDBG("tx_p_v4(%lu)v6(%lu)tx_b_v4(%lu) v6(%lu)\n",
(unsigned long int) data->ipv4_tx_packets,
(unsigned long int) data->ipv6_tx_packets,
(unsigned long int) data->ipv4_tx_bytes,
@ -2834,6 +2967,69 @@ int rmnet_ipa3_query_tethering_stats(struct wan_ioctl_query_tether_stats *data,
return 0;
}
int rmnet_ipa3_query_tethering_stats(struct wan_ioctl_query_tether_stats *data,
bool reset)
{
enum ipa_upstream_type upstream_type;
int rc = 0;
/* get IPA backhaul type */
upstream_type = find_upstream_type(data->upstreamIface);
if (upstream_type == IPA_UPSTEAM_MAX) {
IPAWANERR(" Wrong upstreamIface name %s\n",
data->upstreamIface);
} else if (upstream_type == IPA_UPSTEAM_WLAN) {
IPAWANDBG_LOW(" query wifi-backhaul stats\n");
rc = rmnet_ipa3_query_tethering_stats_wifi(
data, false);
if (rc) {
IPAWANERR("wlan WAN_IOC_QUERY_TETHER_STATS failed\n");
return rc;
}
} else {
IPAWANDBG_LOW(" query modem-backhaul stats\n");
rc = rmnet_ipa3_query_tethering_stats_modem(
data, false);
if (rc) {
IPAWANERR("modem WAN_IOC_QUERY_TETHER_STATS failed\n");
return rc;
}
}
return rc;
}
int rmnet_ipa3_reset_tethering_stats(struct wan_ioctl_reset_tether_stats *data)
{
enum ipa_upstream_type upstream_type;
int rc = 0;
/* get IPA backhaul type */
upstream_type = find_upstream_type(data->upstreamIface);
if (upstream_type == IPA_UPSTEAM_MAX) {
IPAWANERR(" Wrong upstreamIface name %s\n",
data->upstreamIface);
} else if (upstream_type == IPA_UPSTEAM_WLAN) {
IPAWANERR(" reset wifi-backhaul stats\n");
rc = rmnet_ipa3_query_tethering_stats_wifi(
NULL, true);
if (rc) {
IPAWANERR("reset WLAN stats failed\n");
return rc;
}
} else {
IPAWANERR(" reset modem-backhaul stats\n");
rc = rmnet_ipa3_query_tethering_stats_modem(
NULL, true);
if (rc) {
IPAWANERR("reset MODEM stats failed\n");
return rc;
}
}
return rc;
}
/**
* ipa3_broadcast_quota_reach_ind() - Send Netlink broadcast on Quota
* @mux_id - The MUX ID on which the quota has been reached
@ -2843,23 +3039,28 @@ int rmnet_ipa3_query_tethering_stats(struct wan_ioctl_query_tether_stats *data,
* on the specific interface which matches the mux_id has been reached.
*
*/
void ipa3_broadcast_quota_reach_ind(u32 mux_id)
void ipa3_broadcast_quota_reach_ind(u32 mux_id,
enum ipa_upstream_type upstream_type)
{
char alert_msg[IPA_QUOTA_REACH_ALERT_MAX_SIZE];
char iface_name_m[IPA_QUOTA_REACH_IF_NAME_MAX_SIZE];
char iface_name_l[IPA_QUOTA_REACH_IF_NAME_MAX_SIZE];
char *envp[IPA_UEVENT_NUM_EVNP] = {
alert_msg, iface_name_l, iface_name_m, NULL };
alert_msg, iface_name_l, iface_name_m, NULL};
int res;
int index;
index = ipa3_find_mux_channel_index(mux_id);
if (index == MAX_NUM_OF_MUX_CHANNEL) {
IPAWANERR("%u is an mux ID\n", mux_id);
/* check upstream_type*/
if (upstream_type == IPA_UPSTEAM_MAX) {
IPAWANERR(" Wrong upstreamIface type %d\n", upstream_type);
return;
} else if (upstream_type == IPA_UPSTEAM_MODEM) {
index = ipa3_find_mux_channel_index(mux_id);
if (index == MAX_NUM_OF_MUX_CHANNEL) {
IPAWANERR("%u is an mux ID\n", mux_id);
return;
}
}
res = snprintf(alert_msg, IPA_QUOTA_REACH_ALERT_MAX_SIZE,
"ALERT_NAME=%s", "quotaReachedAlert");
if (IPA_QUOTA_REACH_ALERT_MAX_SIZE <= res) {
@ -2867,15 +3068,25 @@ void ipa3_broadcast_quota_reach_ind(u32 mux_id)
return;
}
/* posting msg for L-release for CNE */
if (upstream_type == IPA_UPSTEAM_MODEM) {
res = snprintf(iface_name_l, IPA_QUOTA_REACH_IF_NAME_MAX_SIZE,
"UPSTREAM=%s", rmnet_ipa3_ctx->mux_channel[index].vchannel_name);
} else {
res = snprintf(iface_name_l, IPA_QUOTA_REACH_IF_NAME_MAX_SIZE,
"UPSTREAM=%s", IPA_UPSTEAM_WLAN_IFACE_NAME);
}
if (IPA_QUOTA_REACH_IF_NAME_MAX_SIZE <= res) {
IPAWANERR("message too long (%d)", res);
return;
}
/* posting msg for M-release for CNE */
if (upstream_type == IPA_UPSTEAM_MODEM) {
res = snprintf(iface_name_m, IPA_QUOTA_REACH_IF_NAME_MAX_SIZE,
"INTERFACE=%s", rmnet_ipa3_ctx->mux_channel[index].vchannel_name);
} else {
res = snprintf(iface_name_m, IPA_QUOTA_REACH_IF_NAME_MAX_SIZE,
"INTERFACE=%s", IPA_UPSTEAM_WLAN_IFACE_NAME);
}
if (IPA_QUOTA_REACH_IF_NAME_MAX_SIZE <= res) {
IPAWANERR("message too long (%d)", res);
return;

View file

@ -279,8 +279,9 @@ static long ipa3_wan_ioctl(struct file *filp,
break;
}
if (rmnet_ipa3_query_tethering_stats(NULL, true)) {
IPAWANERR("WAN_IOC_QUERY_TETHER_STATS failed\n");
if (rmnet_ipa3_reset_tethering_stats(
(struct wan_ioctl_reset_tether_stats *)param)) {
IPAWANERR("WAN_IOC_RESET_TETHER_STATS failed\n");
retval = -EFAULT;
break;
}

View file

@ -1066,6 +1066,12 @@ struct ipa_wdi_in_params {
#endif
};
enum ipa_upstream_type {
IPA_UPSTEAM_MODEM = 1,
IPA_UPSTEAM_WLAN,
IPA_UPSTEAM_MAX
};
/**
* struct ipa_wdi_out_params - information provided to WDI client
* @uc_door_bell_pa: physical address of IPA uc doorbell