Jetmir: add tsf set command to sdrctl

This commit is contained in:
Xianjun Jiao 2020-03-05 08:50:41 +01:00
parent b73660ad79
commit e63d1ec300
4 changed files with 87 additions and 4 deletions

View File

@ -60,6 +60,7 @@ addr1|target MAC address of tx slice 1|32bit. for address 6c:fd:b9:4c:b1:c1, you
slice_total1|tx slice 1 cycle length in us|for length 50ms, you set 49999
slice_start1|tx slice 1 cycle start time in us|for start at 10ms, you set 10000
slice_end1| tx slice 1 cycle end time in us|for end at 40ms, you set 39999
tsf| sets TSF value| it requires two values "high_TSF low_TSF". Decimal
### Get and set a register of a module
```

View File

@ -1515,6 +1515,16 @@ static int openwifi_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *
if (nla_put_u32(skb, OPENWIFI_ATTR_RSSI_TH, tmp))
goto nla_put_failure;
return cfg80211_testmode_reply(skb);
case OPENWIFI_CMD_SET_TSF:
printk("openwifi_set_tsf_1");
if ( (!tb[OPENWIFI_ATTR_HIGH_TSF]) || (!tb[OPENWIFI_ATTR_LOW_TSF]) )
return -EINVAL;
printk("openwifi_set_tsf_2");
u32 tsft_high = nla_get_u32(tb[OPENWIFI_ATTR_HIGH_TSF]);
u32 tsft_low = nla_get_u32(tb[OPENWIFI_ATTR_LOW_TSF]);
xpu_api->XPU_REG_TSF_LOAD_VAL_write(tsft_high,tsft_low);
printk("%s openwifi_set_tsf: %08x%08x\n", sdr_compatible_str,tsft_high,tsft_low);
return 0;
case REG_CMD_SET:
if ( (!tb[REG_ATTR_ADDR]) || (!tb[REG_ATTR_VAL]) )

View File

@ -215,6 +215,72 @@ static int handle_set_rssi_th(struct nl80211_state *state,
}
COMMAND(set, rssi_th, "<rssi_th in value>", NL80211_CMD_TESTMODE, 0, CIB_NETDEV, handle_set_rssi_th, "set rssi_th");
static int handle_set_tsf(struct nl80211_state *state,
struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv,
enum id_input id)
{
struct nlattr *tmdata;
char *end;
unsigned int reg_cat, high_tsf, low_tsf;
tmdata = nla_nest_start(msg, NL80211_ATTR_TESTDATA);
if (!tmdata) {
return 1;
}
high_tsf = strtoul(argv[0], &end, 10);
if (*end) {
return 1;
}
low_tsf = strtoul(argv[1], &end, 10);
if (*end) {
return 1;
}
NLA_PUT_U32(msg, OPENWIFI_ATTR_CMD, OPENWIFI_CMD_SET_TSF);
NLA_PUT_U32(msg, OPENWIFI_ATTR_HIGH_TSF, high_tsf);
NLA_PUT_U32(msg, OPENWIFI_ATTR_LOW_TSF, low_tsf);
nla_nest_end(msg, tmdata);
printf("high_tsf val: %08x\n", high_tsf);
printf("low_tsf val: %08x\n", low_tsf);
return 0;
/*struct nlattr *tmdata;
char *end;
unsigned int tmp;
tmdata = nla_nest_start(msg, NL80211_ATTR_TESTDATA);
if (!tmdata) {
return 1;
}
tmp = strtoul(argv[0], &end, 10);
if (*end) {
return 1;
}
NLA_PUT_U32(msg, OPENWIFI_ATTR_CMD, OPENWIFI_CMD_SET_TSF);
NLA_PUT_U64(msg, OPENWIFI_ATTR_TSF, tmp);
nla_nest_end(msg, tmdata);
printf("openwifi tsf: %d\n", tmp);
return 0;*/
nla_put_failure:
return -ENOBUFS;
}
COMMAND(set, tsf, "<high_tsf value low_tsf value>", NL80211_CMD_TESTMODE, 0, CIB_NETDEV, handle_set_tsf, "set tsf");
static int handle_get_rssi_th(struct nl80211_state *state,
struct nl_cb *cb,
struct nl_msg *msg,

View File

@ -14,9 +14,11 @@ enum openwifi_testmode_attr {
OPENWIFI_ATTR_SLICE_START1 = 9,
OPENWIFI_ATTR_SLICE_END1 = 10,
OPENWIFI_ATTR_RSSI_TH = 11,
OPENWIFI_ATTR_HIGH_TSF = 12,
OPENWIFI_ATTR_LOW_TSF = 13,
REG_ATTR_ADDR = 12,
REG_ATTR_VAL = 13,
REG_ATTR_ADDR = 14,
REG_ATTR_VAL = 15,
/* keep last */
__OPENWIFI_ATTR_AFTER_LAST,
@ -54,8 +56,10 @@ enum openwifi_testmode_cmd {
OPENWIFI_CMD_SET_RSSI_TH = 18,
OPENWIFI_CMD_GET_RSSI_TH = 19,
REG_CMD_SET = 20,
REG_CMD_GET = 21,
OPENWIFI_CMD_SET_TSF = 20,
REG_CMD_SET = 21,
REG_CMD_GET = 22,
};
static const struct nla_policy openwifi_testmode_policy[OPENWIFI_ATTR_MAX + 1] = {
@ -70,6 +74,8 @@ static const struct nla_policy openwifi_testmode_policy[OPENWIFI_ATTR_MAX + 1] =
[OPENWIFI_ATTR_SLICE_START1] = { .type = NLA_U32 },
[OPENWIFI_ATTR_SLICE_END1] = { .type = NLA_U32 },
[OPENWIFI_ATTR_RSSI_TH] = { .type = NLA_U32 },
[OPENWIFI_ATTR_HIGH_TSF] = { .type = NLA_U32 },
[OPENWIFI_ATTR_LOW_TSF] = { .type = NLA_U32 },
[REG_ATTR_ADDR] = { .type = NLA_U32 },
[REG_ATTR_VAL] = { .type = NLA_U32 },