qcacld-3.0: Add driver commands to set and get country

Add new driver commands SETCOUNTRYREV and GETCOUNTRYREV to set and get
the country code respectively.

Change-Id: Ia231b2842f127d1e48ffdc110d3d7ec08a15bd6c
CRs-Fixed: 2412656
This commit is contained in:
Rajeev Kumar Sirasanagandla
2019-03-25 16:37:02 +05:30
committed by nshrivas
parent 8c54e38f56
commit 32ae804cfa
2 changed files with 48 additions and 1 deletions

View File

@@ -56,6 +56,13 @@
#define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */
#define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */
/*
* Size of GETCOUNTRYREV output = (sizeof("GETCOUNTRYREV") = 14) + one (space) +
* (sizeof("country_code") = 3) +
* one (NULL terminating character)
*/
#define SIZE_OF_GETCOUNTRYREV_OUTPUT 20
/* /*
* Ibss prop IE from command will be of size: * Ibss prop IE from command will be of size:
* size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length) * size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length)
@@ -2903,6 +2910,40 @@ static inline int drv_cmd_country(struct hdd_adapter *adapter,
return hdd_reg_set_country(hdd_ctx, country_code); return hdd_reg_set_country(hdd_ctx, country_code);
} }
/**
* drv_cmd_get_country() - Helper function to get current county code
* @adapter: pointer to adapter on which request is received
* @hdd_ctx: pointer to hdd context
* @command: command name
* @command_len: command buffer length
* @priv_data: output pointer to hold current country code
*
* Return: On success 0, negative value on error.
*/
static int drv_cmd_get_country(struct hdd_adapter *adapter,
struct hdd_context *hdd_ctx,
uint8_t *command, uint8_t command_len,
struct hdd_priv_data *priv_data)
{
uint8_t buf[SIZE_OF_GETCOUNTRYREV_OUTPUT] = {0};
uint8_t cc[REG_ALPHA2_LEN + 1];
int ret = 0, len;
qdf_mem_copy(cc, hdd_ctx->reg.alpha2, REG_ALPHA2_LEN);
cc[REG_ALPHA2_LEN] = '\0';
len = scnprintf(buf, sizeof(buf), "%s %s",
"GETCOUNTRYREV", cc);
hdd_debug("buf = %s", buf);
len = QDF_MIN(priv_data->total_len, len + 1);
if (copy_to_user(priv_data->buf, buf, len)) {
hdd_err("failed to copy data to user buffer");
ret = -EFAULT;
}
return ret;
}
static int drv_cmd_set_roam_trigger(struct hdd_adapter *adapter, static int drv_cmd_set_roam_trigger(struct hdd_adapter *adapter,
struct hdd_context *hdd_ctx, struct hdd_context *hdd_ctx,
uint8_t *command, uint8_t *command,
@@ -7281,6 +7322,8 @@ static const struct hdd_drv_cmd hdd_drv_cmds[] = {
{"SETBAND", drv_cmd_set_band, true}, {"SETBAND", drv_cmd_set_band, true},
{"SETWMMPS", drv_cmd_set_wmmps, true}, {"SETWMMPS", drv_cmd_set_wmmps, true},
{"COUNTRY", drv_cmd_country, true}, {"COUNTRY", drv_cmd_country, true},
{"SETCOUNTRYREV", drv_cmd_country, true},
{"GETCOUNTRYREV", drv_cmd_get_country, false},
{"SETSUSPENDMODE", drv_cmd_dummy, false}, {"SETSUSPENDMODE", drv_cmd_dummy, false},
{"SET_AP_WPS_P2P_IE", drv_cmd_dummy, false}, {"SET_AP_WPS_P2P_IE", drv_cmd_dummy, false},
{"SETROAMTRIGGER", drv_cmd_set_roam_trigger, true}, {"SETROAMTRIGGER", drv_cmd_set_roam_trigger, true},

View File

@@ -729,13 +729,17 @@ void hdd_program_country_code(struct hdd_context *hdd_ctx)
int hdd_reg_set_country(struct hdd_context *hdd_ctx, char *country_code) int hdd_reg_set_country(struct hdd_context *hdd_ctx, char *country_code)
{ {
QDF_STATUS status; QDF_STATUS status;
uint8_t cc[REG_ALPHA2_LEN + 1];
if (!country_code) { if (!country_code) {
hdd_err("country_code is null"); hdd_err("country_code is null");
return -EINVAL; return -EINVAL;
} }
status = ucfg_reg_set_country(hdd_ctx->pdev, country_code); qdf_mem_copy(cc, country_code, REG_ALPHA2_LEN);
cc[REG_ALPHA2_LEN] = '\0';
status = ucfg_reg_set_country(hdd_ctx->pdev, cc);
if (QDF_IS_STATUS_ERROR(status)) if (QDF_IS_STATUS_ERROR(status))
hdd_err("Failed to set country"); hdd_err("Failed to set country");