in drivers/net/ethernet/intel/i40e/i40e_debugfs.c [699:1549]
static ssize_t i40e_dbg_command_write(struct file *filp,
const char __user *buffer,
size_t count, loff_t *ppos)
{
struct i40e_pf *pf = filp->private_data;
char *cmd_buf, *cmd_buf_tmp;
int bytes_not_copied;
struct i40e_vsi *vsi;
int vsi_seid;
int veb_seid;
int vf_id;
int cnt;
/* don't allow partial writes */
if (*ppos != 0)
return 0;
cmd_buf = kzalloc(count + 1, GFP_KERNEL);
if (!cmd_buf)
return count;
bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
if (bytes_not_copied) {
kfree(cmd_buf);
return -EFAULT;
}
cmd_buf[count] = '\0';
cmd_buf_tmp = strchr(cmd_buf, '\n');
if (cmd_buf_tmp) {
*cmd_buf_tmp = '\0';
count = cmd_buf_tmp - cmd_buf + 1;
}
if (strncmp(cmd_buf, "add vsi", 7) == 0) {
vsi_seid = -1;
cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
if (cnt == 0) {
/* default to PF VSI */
vsi_seid = pf->vsi[pf->lan_vsi]->seid;
} else if (vsi_seid < 0) {
dev_info(&pf->pdev->dev, "add VSI %d: bad vsi seid\n",
vsi_seid);
goto command_write_done;
}
/* By default we are in VEPA mode, if this is the first VF/VMDq
* VSI to be added switch to VEB mode.
*/
if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) {
pf->flags |= I40E_FLAG_VEB_MODE_ENABLED;
i40e_do_reset_safe(pf, I40E_PF_RESET_FLAG);
}
vsi = i40e_vsi_setup(pf, I40E_VSI_VMDQ2, vsi_seid, 0);
if (vsi)
dev_info(&pf->pdev->dev, "added VSI %d to relay %d\n",
vsi->seid, vsi->uplink_seid);
else
dev_info(&pf->pdev->dev, "'%s' failed\n", cmd_buf);
} else if (strncmp(cmd_buf, "del vsi", 7) == 0) {
cnt = sscanf(&cmd_buf[7], "%i", &vsi_seid);
if (cnt != 1) {
dev_info(&pf->pdev->dev,
"del vsi: bad command string, cnt=%d\n",
cnt);
goto command_write_done;
}
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
if (!vsi) {
dev_info(&pf->pdev->dev, "del VSI %d: seid not found\n",
vsi_seid);
goto command_write_done;
}
dev_info(&pf->pdev->dev, "deleting VSI %d\n", vsi_seid);
i40e_vsi_release(vsi);
} else if (strncmp(cmd_buf, "add relay", 9) == 0) {
struct i40e_veb *veb;
int uplink_seid, i;
cnt = sscanf(&cmd_buf[9], "%i %i", &uplink_seid, &vsi_seid);
if (cnt != 2) {
dev_info(&pf->pdev->dev,
"add relay: bad command string, cnt=%d\n",
cnt);
goto command_write_done;
} else if (uplink_seid < 0) {
dev_info(&pf->pdev->dev,
"add relay %d: bad uplink seid\n",
uplink_seid);
goto command_write_done;
}
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
if (!vsi) {
dev_info(&pf->pdev->dev,
"add relay: VSI %d not found\n", vsi_seid);
goto command_write_done;
}
for (i = 0; i < I40E_MAX_VEB; i++)
if (pf->veb[i] && pf->veb[i]->seid == uplink_seid)
break;
if (i >= I40E_MAX_VEB && uplink_seid != 0 &&
uplink_seid != pf->mac_seid) {
dev_info(&pf->pdev->dev,
"add relay: relay uplink %d not found\n",
uplink_seid);
goto command_write_done;
}
veb = i40e_veb_setup(pf, 0, uplink_seid, vsi_seid,
vsi->tc_config.enabled_tc);
if (veb)
dev_info(&pf->pdev->dev, "added relay %d\n", veb->seid);
else
dev_info(&pf->pdev->dev, "add relay failed\n");
} else if (strncmp(cmd_buf, "del relay", 9) == 0) {
int i;
cnt = sscanf(&cmd_buf[9], "%i", &veb_seid);
if (cnt != 1) {
dev_info(&pf->pdev->dev,
"del relay: bad command string, cnt=%d\n",
cnt);
goto command_write_done;
} else if (veb_seid < 0) {
dev_info(&pf->pdev->dev,
"del relay %d: bad relay seid\n", veb_seid);
goto command_write_done;
}
/* find the veb */
for (i = 0; i < I40E_MAX_VEB; i++)
if (pf->veb[i] && pf->veb[i]->seid == veb_seid)
break;
if (i >= I40E_MAX_VEB) {
dev_info(&pf->pdev->dev,
"del relay: relay %d not found\n", veb_seid);
goto command_write_done;
}
dev_info(&pf->pdev->dev, "deleting relay %d\n", veb_seid);
i40e_veb_release(pf->veb[i]);
} else if (strncmp(cmd_buf, "add pvid", 8) == 0) {
i40e_status ret;
u16 vid;
unsigned int v;
cnt = sscanf(&cmd_buf[8], "%i %u", &vsi_seid, &v);
if (cnt != 2) {
dev_info(&pf->pdev->dev,
"add pvid: bad command string, cnt=%d\n", cnt);
goto command_write_done;
}
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
if (!vsi) {
dev_info(&pf->pdev->dev, "add pvid: VSI %d not found\n",
vsi_seid);
goto command_write_done;
}
vid = v;
ret = i40e_vsi_add_pvid(vsi, vid);
if (!ret)
dev_info(&pf->pdev->dev,
"add pvid: %d added to VSI %d\n",
vid, vsi_seid);
else
dev_info(&pf->pdev->dev,
"add pvid: %d to VSI %d failed, ret=%d\n",
vid, vsi_seid, ret);
} else if (strncmp(cmd_buf, "del pvid", 8) == 0) {
cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
if (cnt != 1) {
dev_info(&pf->pdev->dev,
"del pvid: bad command string, cnt=%d\n",
cnt);
goto command_write_done;
}
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
if (!vsi) {
dev_info(&pf->pdev->dev,
"del pvid: VSI %d not found\n", vsi_seid);
goto command_write_done;
}
i40e_vsi_remove_pvid(vsi);
dev_info(&pf->pdev->dev,
"del pvid: removed from VSI %d\n", vsi_seid);
} else if (strncmp(cmd_buf, "dump", 4) == 0) {
if (strncmp(&cmd_buf[5], "switch", 6) == 0) {
i40e_fetch_switch_configuration(pf, true);
} else if (strncmp(&cmd_buf[5], "vsi", 3) == 0) {
cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
if (cnt > 0)
i40e_dbg_dump_vsi_seid(pf, vsi_seid);
else
i40e_dbg_dump_vsi_no_seid(pf);
} else if (strncmp(&cmd_buf[5], "veb", 3) == 0) {
cnt = sscanf(&cmd_buf[8], "%i", &vsi_seid);
if (cnt > 0)
i40e_dbg_dump_veb_seid(pf, vsi_seid);
else
i40e_dbg_dump_veb_all(pf);
} else if (strncmp(&cmd_buf[5], "vf", 2) == 0) {
cnt = sscanf(&cmd_buf[7], "%i", &vf_id);
if (cnt > 0)
i40e_dbg_dump_vf(pf, vf_id);
else
i40e_dbg_dump_vf_all(pf);
} else if (strncmp(&cmd_buf[5], "desc", 4) == 0) {
int ring_id, desc_n;
if (strncmp(&cmd_buf[10], "rx", 2) == 0) {
cnt = sscanf(&cmd_buf[12], "%i %i %i",
&vsi_seid, &ring_id, &desc_n);
i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
desc_n, pf, true);
} else if (strncmp(&cmd_buf[10], "tx", 2)
== 0) {
cnt = sscanf(&cmd_buf[12], "%i %i %i",
&vsi_seid, &ring_id, &desc_n);
i40e_dbg_dump_desc(cnt, vsi_seid, ring_id,
desc_n, pf, false);
} else if (strncmp(&cmd_buf[10], "aq", 2) == 0) {
i40e_dbg_dump_aq_desc(pf);
} else {
dev_info(&pf->pdev->dev,
"dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
dev_info(&pf->pdev->dev,
"dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
dev_info(&pf->pdev->dev, "dump desc aq\n");
}
} else if (strncmp(&cmd_buf[5], "reset stats", 11) == 0) {
dev_info(&pf->pdev->dev,
"core reset count: %d\n", pf->corer_count);
dev_info(&pf->pdev->dev,
"global reset count: %d\n", pf->globr_count);
dev_info(&pf->pdev->dev,
"emp reset count: %d\n", pf->empr_count);
dev_info(&pf->pdev->dev,
"pf reset count: %d\n", pf->pfr_count);
dev_info(&pf->pdev->dev,
"pf tx sluggish count: %d\n",
pf->tx_sluggish_count);
} else if (strncmp(&cmd_buf[5], "port", 4) == 0) {
struct i40e_aqc_query_port_ets_config_resp *bw_data;
struct i40e_dcbx_config *cfg =
&pf->hw.local_dcbx_config;
struct i40e_dcbx_config *r_cfg =
&pf->hw.remote_dcbx_config;
int i, ret;
u16 switch_id;
bw_data = kzalloc(sizeof(
struct i40e_aqc_query_port_ets_config_resp),
GFP_KERNEL);
if (!bw_data) {
ret = -ENOMEM;
goto command_write_done;
}
vsi = pf->vsi[pf->lan_vsi];
switch_id =
le16_to_cpu(vsi->info.switch_id) &
I40E_AQ_VSI_SW_ID_MASK;
ret = i40e_aq_query_port_ets_config(&pf->hw,
switch_id,
bw_data, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"Query Port ETS Config AQ command failed =0x%x\n",
pf->hw.aq.asq_last_status);
kfree(bw_data);
bw_data = NULL;
goto command_write_done;
}
dev_info(&pf->pdev->dev,
"port bw: tc_valid=0x%x tc_strict_prio=0x%x, tc_bw_max=0x%04x,0x%04x\n",
bw_data->tc_valid_bits,
bw_data->tc_strict_priority_bits,
le16_to_cpu(bw_data->tc_bw_max[0]),
le16_to_cpu(bw_data->tc_bw_max[1]));
for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
dev_info(&pf->pdev->dev, "port bw: tc_bw_share=%d tc_bw_limit=%d\n",
bw_data->tc_bw_share_credits[i],
le16_to_cpu(bw_data->tc_bw_limits[i]));
}
kfree(bw_data);
bw_data = NULL;
dev_info(&pf->pdev->dev,
"port dcbx_mode=%d\n", cfg->dcbx_mode);
dev_info(&pf->pdev->dev,
"port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
cfg->etscfg.willing, cfg->etscfg.cbs,
cfg->etscfg.maxtcs);
for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
dev_info(&pf->pdev->dev, "port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
i, cfg->etscfg.prioritytable[i],
cfg->etscfg.tcbwtable[i],
cfg->etscfg.tsatable[i]);
}
for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
dev_info(&pf->pdev->dev, "port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
i, cfg->etsrec.prioritytable[i],
cfg->etsrec.tcbwtable[i],
cfg->etsrec.tsatable[i]);
}
dev_info(&pf->pdev->dev,
"port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
cfg->pfc.willing, cfg->pfc.mbc,
cfg->pfc.pfccap, cfg->pfc.pfcenable);
dev_info(&pf->pdev->dev,
"port app_table: num_apps=%d\n", cfg->numapps);
for (i = 0; i < cfg->numapps; i++) {
dev_info(&pf->pdev->dev, "port app_table: %d prio=%d selector=%d protocol=0x%x\n",
i, cfg->app[i].priority,
cfg->app[i].selector,
cfg->app[i].protocolid);
}
/* Peer TLV DCBX data */
dev_info(&pf->pdev->dev,
"remote port ets_cfg: willing=%d cbs=%d, maxtcs=%d\n",
r_cfg->etscfg.willing,
r_cfg->etscfg.cbs, r_cfg->etscfg.maxtcs);
for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
dev_info(&pf->pdev->dev, "remote port ets_cfg: %d prio_tc=%d tcbw=%d tctsa=%d\n",
i, r_cfg->etscfg.prioritytable[i],
r_cfg->etscfg.tcbwtable[i],
r_cfg->etscfg.tsatable[i]);
}
for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
dev_info(&pf->pdev->dev, "remote port ets_rec: %d prio_tc=%d tcbw=%d tctsa=%d\n",
i, r_cfg->etsrec.prioritytable[i],
r_cfg->etsrec.tcbwtable[i],
r_cfg->etsrec.tsatable[i]);
}
dev_info(&pf->pdev->dev,
"remote port pfc_cfg: willing=%d mbc=%d, pfccap=%d pfcenable=0x%x\n",
r_cfg->pfc.willing,
r_cfg->pfc.mbc,
r_cfg->pfc.pfccap,
r_cfg->pfc.pfcenable);
dev_info(&pf->pdev->dev,
"remote port app_table: num_apps=%d\n",
r_cfg->numapps);
for (i = 0; i < r_cfg->numapps; i++) {
dev_info(&pf->pdev->dev, "remote port app_table: %d prio=%d selector=%d protocol=0x%x\n",
i, r_cfg->app[i].priority,
r_cfg->app[i].selector,
r_cfg->app[i].protocolid);
}
} else if (strncmp(&cmd_buf[5], "debug fwdata", 12) == 0) {
int cluster_id, table_id;
int index, ret;
u16 buff_len = 4096;
u32 next_index;
u8 next_table;
u8 *buff;
u16 rlen;
cnt = sscanf(&cmd_buf[18], "%i %i %i",
&cluster_id, &table_id, &index);
if (cnt != 3) {
dev_info(&pf->pdev->dev,
"dump debug fwdata <cluster_id> <table_id> <index>\n");
goto command_write_done;
}
dev_info(&pf->pdev->dev,
"AQ debug dump fwdata params %x %x %x %x\n",
cluster_id, table_id, index, buff_len);
buff = kzalloc(buff_len, GFP_KERNEL);
if (!buff)
goto command_write_done;
ret = i40e_aq_debug_dump(&pf->hw, cluster_id, table_id,
index, buff_len, buff, &rlen,
&next_table, &next_index,
NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"debug dump fwdata AQ Failed %d 0x%x\n",
ret, pf->hw.aq.asq_last_status);
kfree(buff);
buff = NULL;
goto command_write_done;
}
dev_info(&pf->pdev->dev,
"AQ debug dump fwdata rlen=0x%x next_table=0x%x next_index=0x%x\n",
rlen, next_table, next_index);
print_hex_dump(KERN_INFO, "AQ buffer WB: ",
DUMP_PREFIX_OFFSET, 16, 1,
buff, rlen, true);
kfree(buff);
buff = NULL;
} else {
dev_info(&pf->pdev->dev,
"dump desc tx <vsi_seid> <ring_id> [<desc_n>], dump desc rx <vsi_seid> <ring_id> [<desc_n>],\n");
dev_info(&pf->pdev->dev, "dump switch\n");
dev_info(&pf->pdev->dev, "dump vsi [seid]\n");
dev_info(&pf->pdev->dev, "dump reset stats\n");
dev_info(&pf->pdev->dev, "dump port\n");
dev_info(&pf->pdev->dev, "dump vf [vf_id]\n");
dev_info(&pf->pdev->dev,
"dump debug fwdata <cluster_id> <table_id> <index>\n");
}
} else if (strncmp(cmd_buf, "pfr", 3) == 0) {
dev_info(&pf->pdev->dev, "debugfs: forcing PFR\n");
i40e_do_reset_safe(pf, BIT(__I40E_PF_RESET_REQUESTED));
} else if (strncmp(cmd_buf, "corer", 5) == 0) {
dev_info(&pf->pdev->dev, "debugfs: forcing CoreR\n");
i40e_do_reset_safe(pf, BIT(__I40E_CORE_RESET_REQUESTED));
} else if (strncmp(cmd_buf, "globr", 5) == 0) {
dev_info(&pf->pdev->dev, "debugfs: forcing GlobR\n");
i40e_do_reset_safe(pf, BIT(__I40E_GLOBAL_RESET_REQUESTED));
} else if (strncmp(cmd_buf, "read", 4) == 0) {
u32 address;
u32 value;
cnt = sscanf(&cmd_buf[4], "%i", &address);
if (cnt != 1) {
dev_info(&pf->pdev->dev, "read <reg>\n");
goto command_write_done;
}
/* check the range on address */
if (address > (pf->ioremap_len - sizeof(u32))) {
dev_info(&pf->pdev->dev, "read reg address 0x%08x too large, max=0x%08lx\n",
address, (unsigned long int)(pf->ioremap_len - sizeof(u32)));
goto command_write_done;
}
value = rd32(&pf->hw, address);
dev_info(&pf->pdev->dev, "read: 0x%08x = 0x%08x\n",
address, value);
} else if (strncmp(cmd_buf, "write", 5) == 0) {
u32 address, value;
cnt = sscanf(&cmd_buf[5], "%i %i", &address, &value);
if (cnt != 2) {
dev_info(&pf->pdev->dev, "write <reg> <value>\n");
goto command_write_done;
}
/* check the range on address */
if (address > (pf->ioremap_len - sizeof(u32))) {
dev_info(&pf->pdev->dev, "write reg address 0x%08x too large, max=0x%08lx\n",
address, (unsigned long int)(pf->ioremap_len - sizeof(u32)));
goto command_write_done;
}
wr32(&pf->hw, address, value);
value = rd32(&pf->hw, address);
dev_info(&pf->pdev->dev, "write: 0x%08x = 0x%08x\n",
address, value);
} else if (strncmp(cmd_buf, "clear_stats", 11) == 0) {
if (strncmp(&cmd_buf[12], "vsi", 3) == 0) {
cnt = sscanf(&cmd_buf[15], "%i", &vsi_seid);
if (cnt == 0) {
int i;
for (i = 0; i < pf->num_alloc_vsi; i++)
i40e_vsi_reset_stats(pf->vsi[i]);
dev_info(&pf->pdev->dev, "vsi clear stats called for all vsi's\n");
} else if (cnt == 1) {
vsi = i40e_dbg_find_vsi(pf, vsi_seid);
if (!vsi) {
dev_info(&pf->pdev->dev,
"clear_stats vsi: bad vsi %d\n",
vsi_seid);
goto command_write_done;
}
i40e_vsi_reset_stats(vsi);
dev_info(&pf->pdev->dev,
"vsi clear stats called for vsi %d\n",
vsi_seid);
} else {
dev_info(&pf->pdev->dev, "clear_stats vsi [seid]\n");
}
} else if (strncmp(&cmd_buf[12], "port", 4) == 0) {
if (pf->hw.partition_id == 1) {
i40e_pf_reset_stats(pf);
dev_info(&pf->pdev->dev, "port stats cleared\n");
} else {
dev_info(&pf->pdev->dev, "clear port stats not allowed on this port partition\n");
}
} else {
dev_info(&pf->pdev->dev, "clear_stats vsi [seid] or clear_stats port\n");
}
} else if (strncmp(cmd_buf, "send aq_cmd", 11) == 0) {
struct i40e_aq_desc *desc;
i40e_status ret;
desc = kzalloc(sizeof(struct i40e_aq_desc), GFP_KERNEL);
if (!desc)
goto command_write_done;
cnt = sscanf(&cmd_buf[11],
"%hi %hi %hi %hi %i %i %i %i %i %i",
&desc->flags,
&desc->opcode, &desc->datalen, &desc->retval,
&desc->cookie_high, &desc->cookie_low,
&desc->params.internal.param0,
&desc->params.internal.param1,
&desc->params.internal.param2,
&desc->params.internal.param3);
if (cnt != 10) {
dev_info(&pf->pdev->dev,
"send aq_cmd: bad command string, cnt=%d\n",
cnt);
kfree(desc);
desc = NULL;
goto command_write_done;
}
ret = i40e_asq_send_command(&pf->hw, desc, NULL, 0, NULL);
if (!ret) {
dev_info(&pf->pdev->dev, "AQ command sent Status : Success\n");
} else if (ret == I40E_ERR_ADMIN_QUEUE_ERROR) {
dev_info(&pf->pdev->dev,
"AQ command send failed Opcode %x AQ Error: %d\n",
desc->opcode, pf->hw.aq.asq_last_status);
} else {
dev_info(&pf->pdev->dev,
"AQ command send failed Opcode %x Status: %d\n",
desc->opcode, ret);
}
dev_info(&pf->pdev->dev,
"AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
desc->flags, desc->opcode, desc->datalen, desc->retval,
desc->cookie_high, desc->cookie_low,
desc->params.internal.param0,
desc->params.internal.param1,
desc->params.internal.param2,
desc->params.internal.param3);
kfree(desc);
desc = NULL;
} else if (strncmp(cmd_buf, "send indirect aq_cmd", 20) == 0) {
struct i40e_aq_desc *desc;
i40e_status ret;
u16 buffer_len;
u8 *buff;
desc = kzalloc(sizeof(struct i40e_aq_desc), GFP_KERNEL);
if (!desc)
goto command_write_done;
cnt = sscanf(&cmd_buf[20],
"%hi %hi %hi %hi %i %i %i %i %i %i %hi",
&desc->flags,
&desc->opcode, &desc->datalen, &desc->retval,
&desc->cookie_high, &desc->cookie_low,
&desc->params.internal.param0,
&desc->params.internal.param1,
&desc->params.internal.param2,
&desc->params.internal.param3,
&buffer_len);
if (cnt != 11) {
dev_info(&pf->pdev->dev,
"send indirect aq_cmd: bad command string, cnt=%d\n",
cnt);
kfree(desc);
desc = NULL;
goto command_write_done;
}
/* Just stub a buffer big enough in case user messed up */
if (buffer_len == 0)
buffer_len = 1280;
buff = kzalloc(buffer_len, GFP_KERNEL);
if (!buff) {
kfree(desc);
desc = NULL;
goto command_write_done;
}
desc->flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
ret = i40e_asq_send_command(&pf->hw, desc, buff,
buffer_len, NULL);
if (!ret) {
dev_info(&pf->pdev->dev, "AQ command sent Status : Success\n");
} else if (ret == I40E_ERR_ADMIN_QUEUE_ERROR) {
dev_info(&pf->pdev->dev,
"AQ command send failed Opcode %x AQ Error: %d\n",
desc->opcode, pf->hw.aq.asq_last_status);
} else {
dev_info(&pf->pdev->dev,
"AQ command send failed Opcode %x Status: %d\n",
desc->opcode, ret);
}
dev_info(&pf->pdev->dev,
"AQ desc WB 0x%04x 0x%04x 0x%04x 0x%04x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
desc->flags, desc->opcode, desc->datalen, desc->retval,
desc->cookie_high, desc->cookie_low,
desc->params.internal.param0,
desc->params.internal.param1,
desc->params.internal.param2,
desc->params.internal.param3);
print_hex_dump(KERN_INFO, "AQ buffer WB: ",
DUMP_PREFIX_OFFSET, 16, 1,
buff, buffer_len, true);
kfree(buff);
buff = NULL;
kfree(desc);
desc = NULL;
} else if (strncmp(cmd_buf, "fd current cnt", 14) == 0) {
dev_info(&pf->pdev->dev, "FD current total filter count for this interface: %d\n",
i40e_get_current_fd_count(pf));
} else if (strncmp(cmd_buf, "lldp", 4) == 0) {
if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
int ret;
ret = i40e_aq_stop_lldp(&pf->hw, false, false, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"Stop LLDP AQ command failed =0x%x\n",
pf->hw.aq.asq_last_status);
goto command_write_done;
}
ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
pf->hw.mac.addr,
ETH_P_LLDP, 0,
pf->vsi[pf->lan_vsi]->seid,
0, true, NULL, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"%s: Add Control Packet Filter AQ command failed =0x%x\n",
__func__, pf->hw.aq.asq_last_status);
goto command_write_done;
}
#ifdef CONFIG_I40E_DCB
pf->dcbx_cap = DCB_CAP_DCBX_HOST |
DCB_CAP_DCBX_VER_IEEE;
#endif /* CONFIG_I40E_DCB */
} else if (strncmp(&cmd_buf[5], "start", 5) == 0) {
int ret;
ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
pf->hw.mac.addr,
ETH_P_LLDP, 0,
pf->vsi[pf->lan_vsi]->seid,
0, false, NULL, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"%s: Remove Control Packet Filter AQ command failed =0x%x\n",
__func__, pf->hw.aq.asq_last_status);
/* Continue and start FW LLDP anyways */
}
ret = i40e_aq_start_lldp(&pf->hw, false, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"Start LLDP AQ command failed =0x%x\n",
pf->hw.aq.asq_last_status);
goto command_write_done;
}
#ifdef CONFIG_I40E_DCB
pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED |
DCB_CAP_DCBX_VER_IEEE;
#endif /* CONFIG_I40E_DCB */
} else if (strncmp(&cmd_buf[5],
"get local", 9) == 0) {
u16 llen, rlen;
int ret;
u8 *buff;
buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
if (!buff)
goto command_write_done;
ret = i40e_aq_get_lldp_mib(&pf->hw, 0,
I40E_AQ_LLDP_MIB_LOCAL,
buff, I40E_LLDPDU_SIZE,
&llen, &rlen, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"Get LLDP MIB (local) AQ command failed =0x%x\n",
pf->hw.aq.asq_last_status);
kfree(buff);
buff = NULL;
goto command_write_done;
}
dev_info(&pf->pdev->dev, "LLDP MIB (local)\n");
print_hex_dump(KERN_INFO, "LLDP MIB (local): ",
DUMP_PREFIX_OFFSET, 16, 1,
buff, I40E_LLDPDU_SIZE, true);
kfree(buff);
buff = NULL;
} else if (strncmp(&cmd_buf[5], "get remote", 10) == 0) {
u16 llen, rlen;
int ret;
u8 *buff;
buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
if (!buff)
goto command_write_done;
ret = i40e_aq_get_lldp_mib(&pf->hw,
I40E_AQ_LLDP_BRIDGE_TYPE_NEAREST_BRIDGE,
I40E_AQ_LLDP_MIB_REMOTE,
buff, I40E_LLDPDU_SIZE,
&llen, &rlen, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"Get LLDP MIB (remote) AQ command failed =0x%x\n",
pf->hw.aq.asq_last_status);
kfree(buff);
buff = NULL;
goto command_write_done;
}
dev_info(&pf->pdev->dev, "LLDP MIB (remote)\n");
print_hex_dump(KERN_INFO, "LLDP MIB (remote): ",
DUMP_PREFIX_OFFSET, 16, 1,
buff, I40E_LLDPDU_SIZE, true);
kfree(buff);
buff = NULL;
} else if (strncmp(&cmd_buf[5], "event on", 8) == 0) {
int ret;
ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
true, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"Config LLDP MIB Change Event (on) AQ command failed =0x%x\n",
pf->hw.aq.asq_last_status);
goto command_write_done;
}
} else if (strncmp(&cmd_buf[5], "event off", 9) == 0) {
int ret;
ret = i40e_aq_cfg_lldp_mib_change_event(&pf->hw,
false, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
"Config LLDP MIB Change Event (off) AQ command failed =0x%x\n",
pf->hw.aq.asq_last_status);
goto command_write_done;
}
}
} else if (strncmp(cmd_buf, "nvm read", 8) == 0) {
u16 buffer_len, bytes;
u16 module;
u32 offset;
u16 *buff;
int ret;
cnt = sscanf(&cmd_buf[8], "%hx %x %hx",
&module, &offset, &buffer_len);
if (cnt == 0) {
module = 0;
offset = 0;
buffer_len = 0;
} else if (cnt == 1) {
offset = 0;
buffer_len = 0;
} else if (cnt == 2) {
buffer_len = 0;
} else if (cnt > 3) {
dev_info(&pf->pdev->dev,
"nvm read: bad command string, cnt=%d\n", cnt);
goto command_write_done;
}
/* set the max length */
buffer_len = min_t(u16, buffer_len, I40E_MAX_AQ_BUF_SIZE/2);
bytes = 2 * buffer_len;
/* read at least 1k bytes, no more than 4kB */
bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE);
buff = kzalloc(bytes, GFP_KERNEL);
if (!buff)
goto command_write_done;
ret = i40e_acquire_nvm(&pf->hw, I40E_RESOURCE_READ);
if (ret) {
dev_info(&pf->pdev->dev,
"Failed Acquiring NVM resource for read err=%d status=0x%x\n",
ret, pf->hw.aq.asq_last_status);
kfree(buff);
goto command_write_done;
}
ret = i40e_aq_read_nvm(&pf->hw, module, (2 * offset),
bytes, (u8 *)buff, true, NULL);
i40e_release_nvm(&pf->hw);
if (ret) {
dev_info(&pf->pdev->dev,
"Read NVM AQ failed err=%d status=0x%x\n",
ret, pf->hw.aq.asq_last_status);
} else {
dev_info(&pf->pdev->dev,
"Read NVM module=0x%x offset=0x%x words=%d\n",
module, offset, buffer_len);
if (bytes)
print_hex_dump(KERN_INFO, "NVM Dump: ",
DUMP_PREFIX_OFFSET, 16, 2,
buff, bytes, true);
}
kfree(buff);
buff = NULL;
} else {
dev_info(&pf->pdev->dev, "unknown command '%s'\n", cmd_buf);
dev_info(&pf->pdev->dev, "available commands\n");
dev_info(&pf->pdev->dev, " add vsi [relay_seid]\n");
dev_info(&pf->pdev->dev, " del vsi [vsi_seid]\n");
dev_info(&pf->pdev->dev, " add relay <uplink_seid> <vsi_seid>\n");
dev_info(&pf->pdev->dev, " del relay <relay_seid>\n");
dev_info(&pf->pdev->dev, " add pvid <vsi_seid> <vid>\n");
dev_info(&pf->pdev->dev, " del pvid <vsi_seid>\n");
dev_info(&pf->pdev->dev, " dump switch\n");
dev_info(&pf->pdev->dev, " dump vsi [seid]\n");
dev_info(&pf->pdev->dev, " dump desc tx <vsi_seid> <ring_id> [<desc_n>]\n");
dev_info(&pf->pdev->dev, " dump desc rx <vsi_seid> <ring_id> [<desc_n>]\n");
dev_info(&pf->pdev->dev, " dump desc aq\n");
dev_info(&pf->pdev->dev, " dump reset stats\n");
dev_info(&pf->pdev->dev, " dump debug fwdata <cluster_id> <table_id> <index>\n");
dev_info(&pf->pdev->dev, " read <reg>\n");
dev_info(&pf->pdev->dev, " write <reg> <value>\n");
dev_info(&pf->pdev->dev, " clear_stats vsi [seid]\n");
dev_info(&pf->pdev->dev, " clear_stats port\n");
dev_info(&pf->pdev->dev, " pfr\n");
dev_info(&pf->pdev->dev, " corer\n");
dev_info(&pf->pdev->dev, " globr\n");
dev_info(&pf->pdev->dev, " send aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3>\n");
dev_info(&pf->pdev->dev, " send indirect aq_cmd <flags> <opcode> <datalen> <retval> <cookie_h> <cookie_l> <param0> <param1> <param2> <param3> <buffer_len>\n");
dev_info(&pf->pdev->dev, " fd current cnt");
dev_info(&pf->pdev->dev, " lldp start\n");
dev_info(&pf->pdev->dev, " lldp stop\n");
dev_info(&pf->pdev->dev, " lldp get local\n");
dev_info(&pf->pdev->dev, " lldp get remote\n");
dev_info(&pf->pdev->dev, " lldp event on\n");
dev_info(&pf->pdev->dev, " lldp event off\n");
dev_info(&pf->pdev->dev, " nvm read [module] [word_offset] [word_count]\n");
}
command_write_done:
kfree(cmd_buf);
cmd_buf = NULL;
return count;
}