Skip to content

Commit

Permalink
i40e/i40evf: clean up some code
Browse files Browse the repository at this point in the history
Add missings spaces after declarations, remove another __func__ use,
remove uncessary braces, remove unneeded breaks, and useless returns,
and generally fix up some code.

Change-ID: Ie715d6b64976c50e1c21531685fe0a2bd38c4244
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
  • Loading branch information
jbrandeb authored and Jeff Kirsher committed Oct 8, 2015
1 parent ee5c1e9 commit 6995b36
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 103 deletions.
3 changes: 1 addition & 2 deletions drivers/net/ethernet/intel/i40e/i40e_adminq.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,7 @@ static u16 i40e_clean_asq(struct i40e_hw *hw)
details = I40E_ADMINQ_DETAILS(*asq, ntc);
while (rd32(hw, hw->aq.asq.head) != ntc) {
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE,
"%s: ntc %d head %d.\n", __func__, ntc,
rd32(hw, hw->aq.asq.head));
"ntc %d head %d.\n", ntc, rd32(hw, hw->aq.asq.head));

if (details->callback) {
I40E_ADMINQ_CALLBACK cb_func =
Expand Down
9 changes: 5 additions & 4 deletions drivers/net/ethernet/intel/i40e/i40e_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ i40e_status i40e_get_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
status = i40e_aq_mac_address_read(hw, &flags, &addrs, NULL);

if (flags & I40E_AQC_LAN_ADDR_VALID)
memcpy(mac_addr, &addrs.pf_lan_mac, sizeof(addrs.pf_lan_mac));
ether_addr_copy(mac_addr, addrs.pf_lan_mac);

return status;
}
Expand All @@ -1058,7 +1058,7 @@ i40e_status i40e_get_port_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
return status;

if (flags & I40E_AQC_PORT_ADDR_VALID)
memcpy(mac_addr, &addrs.port_mac, sizeof(addrs.port_mac));
ether_addr_copy(mac_addr, addrs.port_mac);
else
status = I40E_ERR_INVALID_MAC_ADDR;

Expand Down Expand Up @@ -1116,7 +1116,7 @@ i40e_status i40e_get_san_mac_addr(struct i40e_hw *hw, u8 *mac_addr)
return status;

if (flags & I40E_AQC_SAN_ADDR_VALID)
memcpy(mac_addr, &addrs.pf_san_mac, sizeof(addrs.pf_san_mac));
ether_addr_copy(mac_addr, addrs.pf_san_mac);
else
status = I40E_ERR_INVALID_MAC_ADDR;

Expand Down Expand Up @@ -2363,6 +2363,7 @@ i40e_status i40e_aq_get_veb_parameters(struct i40e_hw *hw,
*vebs_free = le16_to_cpu(cmd_resp->vebs_free);
if (floating) {
u16 flags = le16_to_cpu(cmd_resp->veb_flags);

if (flags & I40E_AQC_ADD_VEB_FLOATING)
*floating = true;
else
Expand Down Expand Up @@ -3777,7 +3778,7 @@ i40e_status i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
}

if (mac_addr)
memcpy(cmd->mac, mac_addr, ETH_ALEN);
ether_addr_copy(cmd->mac, mac_addr);

cmd->etype = cpu_to_le16(ethtype);
cmd->flags = cpu_to_le16(flags);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/intel/i40e/i40e_dcb_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ static void i40e_dcbnl_del_app(struct i40e_pf *pf,
struct i40e_dcb_app_priority_table *app)
{
int v, err;

for (v = 0; v < pf->num_alloc_vsi; v++) {
if (pf->vsi[v] && pf->vsi[v]->netdev) {
err = i40e_dcbnl_vsi_del_app(pf->vsi[v], app);
Expand Down
124 changes: 72 additions & 52 deletions drivers/net/ethernet/intel/i40e/i40e_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,89 +404,90 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
nstat = i40e_get_vsi_stats_struct(vsi);
dev_info(&pf->pdev->dev,
" net_stats: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
(long unsigned int)nstat->rx_packets,
(long unsigned int)nstat->rx_bytes,
(long unsigned int)nstat->rx_errors,
(long unsigned int)nstat->rx_dropped);
(unsigned long int)nstat->rx_packets,
(unsigned long int)nstat->rx_bytes,
(unsigned long int)nstat->rx_errors,
(unsigned long int)nstat->rx_dropped);
dev_info(&pf->pdev->dev,
" net_stats: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
(long unsigned int)nstat->tx_packets,
(long unsigned int)nstat->tx_bytes,
(long unsigned int)nstat->tx_errors,
(long unsigned int)nstat->tx_dropped);
(unsigned long int)nstat->tx_packets,
(unsigned long int)nstat->tx_bytes,
(unsigned long int)nstat->tx_errors,
(unsigned long int)nstat->tx_dropped);
dev_info(&pf->pdev->dev,
" net_stats: multicast = %lu, collisions = %lu\n",
(long unsigned int)nstat->multicast,
(long unsigned int)nstat->collisions);
(unsigned long int)nstat->multicast,
(unsigned long int)nstat->collisions);
dev_info(&pf->pdev->dev,
" net_stats: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
(long unsigned int)nstat->rx_length_errors,
(long unsigned int)nstat->rx_over_errors,
(long unsigned int)nstat->rx_crc_errors);
(unsigned long int)nstat->rx_length_errors,
(unsigned long int)nstat->rx_over_errors,
(unsigned long int)nstat->rx_crc_errors);
dev_info(&pf->pdev->dev,
" net_stats: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
(long unsigned int)nstat->rx_frame_errors,
(long unsigned int)nstat->rx_fifo_errors,
(long unsigned int)nstat->rx_missed_errors);
(unsigned long int)nstat->rx_frame_errors,
(unsigned long int)nstat->rx_fifo_errors,
(unsigned long int)nstat->rx_missed_errors);
dev_info(&pf->pdev->dev,
" net_stats: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
(long unsigned int)nstat->tx_aborted_errors,
(long unsigned int)nstat->tx_carrier_errors,
(long unsigned int)nstat->tx_fifo_errors);
(unsigned long int)nstat->tx_aborted_errors,
(unsigned long int)nstat->tx_carrier_errors,
(unsigned long int)nstat->tx_fifo_errors);
dev_info(&pf->pdev->dev,
" net_stats: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
(long unsigned int)nstat->tx_heartbeat_errors,
(long unsigned int)nstat->tx_window_errors);
(unsigned long int)nstat->tx_heartbeat_errors,
(unsigned long int)nstat->tx_window_errors);
dev_info(&pf->pdev->dev,
" net_stats: rx_compressed = %lu, tx_compressed = %lu\n",
(long unsigned int)nstat->rx_compressed,
(long unsigned int)nstat->tx_compressed);
(unsigned long int)nstat->rx_compressed,
(unsigned long int)nstat->tx_compressed);
dev_info(&pf->pdev->dev,
" net_stats_offsets: rx_packets = %lu, rx_bytes = %lu, rx_errors = %lu, rx_dropped = %lu\n",
(long unsigned int)vsi->net_stats_offsets.rx_packets,
(long unsigned int)vsi->net_stats_offsets.rx_bytes,
(long unsigned int)vsi->net_stats_offsets.rx_errors,
(long unsigned int)vsi->net_stats_offsets.rx_dropped);
(unsigned long int)vsi->net_stats_offsets.rx_packets,
(unsigned long int)vsi->net_stats_offsets.rx_bytes,
(unsigned long int)vsi->net_stats_offsets.rx_errors,
(unsigned long int)vsi->net_stats_offsets.rx_dropped);
dev_info(&pf->pdev->dev,
" net_stats_offsets: tx_packets = %lu, tx_bytes = %lu, tx_errors = %lu, tx_dropped = %lu\n",
(long unsigned int)vsi->net_stats_offsets.tx_packets,
(long unsigned int)vsi->net_stats_offsets.tx_bytes,
(long unsigned int)vsi->net_stats_offsets.tx_errors,
(long unsigned int)vsi->net_stats_offsets.tx_dropped);
(unsigned long int)vsi->net_stats_offsets.tx_packets,
(unsigned long int)vsi->net_stats_offsets.tx_bytes,
(unsigned long int)vsi->net_stats_offsets.tx_errors,
(unsigned long int)vsi->net_stats_offsets.tx_dropped);
dev_info(&pf->pdev->dev,
" net_stats_offsets: multicast = %lu, collisions = %lu\n",
(long unsigned int)vsi->net_stats_offsets.multicast,
(long unsigned int)vsi->net_stats_offsets.collisions);
(unsigned long int)vsi->net_stats_offsets.multicast,
(unsigned long int)vsi->net_stats_offsets.collisions);
dev_info(&pf->pdev->dev,
" net_stats_offsets: rx_length_errors = %lu, rx_over_errors = %lu, rx_crc_errors = %lu\n",
(long unsigned int)vsi->net_stats_offsets.rx_length_errors,
(long unsigned int)vsi->net_stats_offsets.rx_over_errors,
(long unsigned int)vsi->net_stats_offsets.rx_crc_errors);
(unsigned long int)vsi->net_stats_offsets.rx_length_errors,
(unsigned long int)vsi->net_stats_offsets.rx_over_errors,
(unsigned long int)vsi->net_stats_offsets.rx_crc_errors);
dev_info(&pf->pdev->dev,
" net_stats_offsets: rx_frame_errors = %lu, rx_fifo_errors = %lu, rx_missed_errors = %lu\n",
(long unsigned int)vsi->net_stats_offsets.rx_frame_errors,
(long unsigned int)vsi->net_stats_offsets.rx_fifo_errors,
(long unsigned int)vsi->net_stats_offsets.rx_missed_errors);
(unsigned long int)vsi->net_stats_offsets.rx_frame_errors,
(unsigned long int)vsi->net_stats_offsets.rx_fifo_errors,
(unsigned long int)vsi->net_stats_offsets.rx_missed_errors);
dev_info(&pf->pdev->dev,
" net_stats_offsets: tx_aborted_errors = %lu, tx_carrier_errors = %lu, tx_fifo_errors = %lu\n",
(long unsigned int)vsi->net_stats_offsets.tx_aborted_errors,
(long unsigned int)vsi->net_stats_offsets.tx_carrier_errors,
(long unsigned int)vsi->net_stats_offsets.tx_fifo_errors);
(unsigned long int)vsi->net_stats_offsets.tx_aborted_errors,
(unsigned long int)vsi->net_stats_offsets.tx_carrier_errors,
(unsigned long int)vsi->net_stats_offsets.tx_fifo_errors);
dev_info(&pf->pdev->dev,
" net_stats_offsets: tx_heartbeat_errors = %lu, tx_window_errors = %lu\n",
(long unsigned int)vsi->net_stats_offsets.tx_heartbeat_errors,
(long unsigned int)vsi->net_stats_offsets.tx_window_errors);
(unsigned long int)vsi->net_stats_offsets.tx_heartbeat_errors,
(unsigned long int)vsi->net_stats_offsets.tx_window_errors);
dev_info(&pf->pdev->dev,
" net_stats_offsets: rx_compressed = %lu, tx_compressed = %lu\n",
(long unsigned int)vsi->net_stats_offsets.rx_compressed,
(long unsigned int)vsi->net_stats_offsets.tx_compressed);
(unsigned long int)vsi->net_stats_offsets.rx_compressed,
(unsigned long int)vsi->net_stats_offsets.tx_compressed);
dev_info(&pf->pdev->dev,
" tx_restart = %d, tx_busy = %d, rx_buf_failed = %d, rx_page_failed = %d\n",
vsi->tx_restart, vsi->tx_busy,
vsi->rx_buf_failed, vsi->rx_page_failed);
rcu_read_lock();
for (i = 0; i < vsi->num_queue_pairs; i++) {
struct i40e_ring *rx_ring = ACCESS_ONCE(vsi->rx_rings[i]);

if (!rx_ring)
continue;

Expand Down Expand Up @@ -527,14 +528,15 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
dev_info(&pf->pdev->dev,
" rx_rings[%i]: size = %i, dma = 0x%08lx\n",
i, rx_ring->size,
(long unsigned int)rx_ring->dma);
(unsigned long int)rx_ring->dma);
dev_info(&pf->pdev->dev,
" rx_rings[%i]: vsi = %p, q_vector = %p\n",
i, rx_ring->vsi,
rx_ring->q_vector);
}
for (i = 0; i < vsi->num_queue_pairs; i++) {
struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[i]);

if (!tx_ring)
continue;

Expand Down Expand Up @@ -573,7 +575,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
dev_info(&pf->pdev->dev,
" tx_rings[%i]: size = %i, dma = 0x%08lx\n",
i, tx_ring->size,
(long unsigned int)tx_ring->dma);
(unsigned long int)tx_ring->dma);
dev_info(&pf->pdev->dev,
" tx_rings[%i]: vsi = %p, q_vector = %p\n",
i, tx_ring->vsi,
Expand Down Expand Up @@ -743,6 +745,7 @@ static void i40e_dbg_dump_aq_desc(struct i40e_pf *pf)
ring = &(hw->aq.asq);
for (i = 0; i < ring->count; i++) {
struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);

dev_info(&pf->pdev->dev,
" at[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
i, d->flags, d->opcode, d->datalen, d->retval,
Expand All @@ -755,6 +758,7 @@ static void i40e_dbg_dump_aq_desc(struct i40e_pf *pf)
ring = &(hw->aq.arq);
for (i = 0; i < ring->count; i++) {
struct i40e_aq_desc *d = I40E_ADMINQ_DESC(*ring, i);

dev_info(&pf->pdev->dev,
" ar[%02d] flags=0x%04x op=0x%04x dlen=0x%04x ret=0x%04x cookie_h=0x%08x cookie_l=0x%08x\n",
i, d->flags, d->opcode, d->datalen, d->retval,
Expand Down Expand Up @@ -1038,7 +1042,13 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
dev_info(&pf->pdev->dev, "'%s' failed\n", cmd_buf);

} else if (strncmp(cmd_buf, "del vsi", 7) == 0) {
sscanf(&cmd_buf[7], "%i", &vsi_seid);
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",
Expand Down Expand Up @@ -1488,6 +1498,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
} 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");
Expand All @@ -1507,6 +1518,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,

} 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");
Expand All @@ -1528,6 +1540,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
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");
Expand Down Expand Up @@ -1726,8 +1739,9 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
packet_len, I40E_FDIR_MAX_RAW_PACKET_SIZE);

for (i = 0; i < packet_len; i++) {
sscanf(&asc_packet[j], "%2hhx ",
&raw_packet[i]);
cnt = sscanf(&asc_packet[j], "%2hhx ", &raw_packet[i]);
if (!cnt)
break;
j += 3;
}
dev_info(&pf->pdev->dev, "FD raw packet dump\n");
Expand Down Expand Up @@ -1755,6 +1769,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
} 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, NULL);
if (ret) {
dev_info(&pf->pdev->dev,
Expand All @@ -1779,6 +1794,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
#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,
I40E_ETH_P_LLDP, 0,
Expand Down Expand Up @@ -1807,6 +1823,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
u16 llen, rlen;
int ret;
u8 *buff;

buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
if (!buff)
goto command_write_done;
Expand All @@ -1833,6 +1850,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
u16 llen, rlen;
int ret;
u8 *buff;

buff = kzalloc(I40E_LLDPDU_SIZE, GFP_KERNEL);
if (!buff)
goto command_write_done;
Expand All @@ -1858,6 +1876,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
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) {
Expand All @@ -1868,6 +1887,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
}
} 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) {
Expand Down Expand Up @@ -2105,6 +2125,7 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
}
} else if (strncmp(i40e_dbg_netdev_ops_buf, "change_mtu", 10) == 0) {
int mtu;

cnt = sscanf(&i40e_dbg_netdev_ops_buf[11], "%i %i",
&vsi_seid, &mtu);
if (cnt != 2) {
Expand Down Expand Up @@ -2220,7 +2241,6 @@ void i40e_dbg_pf_init(struct i40e_pf *pf)
create_failed:
dev_info(dev, "debugfs dir/file for %s failed\n", name);
debugfs_remove_recursive(pf->i40e_dbg_pf);
return;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/intel/i40e/i40e_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
if ((pf->lan_veb != I40E_NO_VEB) &&
(pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) {
struct i40e_veb *veb = pf->veb[pf->lan_veb];

for (j = 0; j < I40E_VEB_STATS_LEN; j++) {
p = (char *)veb;
p += i40e_gstrings_veb_stats[j].stat_offset;
Expand Down Expand Up @@ -1607,7 +1608,7 @@ static inline bool i40e_active_vfs(struct i40e_pf *pf)
int i;

for (i = 0; i < pf->num_alloc_vfs; i++)
if (vfs[i].vf_states & I40E_VF_STAT_ACTIVE)
if (test_bit(I40E_VF_STAT_ACTIVE, &vfs[i].vf_states))
return true;
return false;
}
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/intel/i40e/i40e_fcoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ void i40e_init_pf_fcoe(struct i40e_pf *pf)
wr32(hw, I40E_GLFCOE_RCTL, val);

dev_info(&pf->pdev->dev, "FCoE is supported.\n");
return;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/intel/i40e/i40e_lan_hmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,8 @@ static i40e_status i40e_create_lan_hmc_object(struct i40e_hw *hw,
pd_idx1 = max(pd_idx,
((j - 1) * I40E_HMC_MAX_BP_COUNT));
pd_lmt1 = min(pd_lmt, (j * I40E_HMC_MAX_BP_COUNT));
for (i = pd_idx1; i < pd_lmt1; i++) {
for (i = pd_idx1; i < pd_lmt1; i++)
i40e_remove_pd_bp(hw, info->hmc_info, i);
}
i40e_remove_pd_page(hw, info->hmc_info, (j - 1));
break;
case I40E_SD_TYPE_DIRECT:
Expand Down
Loading

0 comments on commit 6995b36

Please sign in to comment.