Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6995b36c authored by Jesse Brandeburg's avatar Jesse Brandeburg Committed by Jeff Kirsher
Browse files

i40e/i40evf: clean up some code



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: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: default avatarShannon Nelson <shannon.nelson@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent ee5c1e92
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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 =
+5 −4
Original line number Diff line number Diff line
@@ -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;
}
@@ -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;

@@ -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;

@@ -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
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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);
+72 −52
Original line number Diff line number Diff line
@@ -404,82 +404,82 @@ 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,
@@ -487,6 +487,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
	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;

@@ -527,7 +528,7 @@ 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,
@@ -535,6 +536,7 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)
	}
	for (i = 0; i < vsi->num_queue_pairs; i++) {
		struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[i]);

		if (!tx_ring)
			continue;

@@ -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,
@@ -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,
@@ -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,
@@ -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",
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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,
@@ -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,
@@ -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;
@@ -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;
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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;
}

/**
+2 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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;
}
Loading